bool SaveSubyear() { using (var helper = new DbHelper.Structure()) { var subyear = new Academic.DbEntities.Structure.SubYear() { Name = txtName.Text , Description = txtDescription.Text , Id = this.StructureId , YearId = ParentId , Position = Convert.ToInt32(string.IsNullOrEmpty(txtPosition.Text) ? "0" : txtPosition.Text) }; if (StructureId == 0) { subyear.CreatedDate = DateTime.Now; } var saved = helper.AddOrUpdateSubYear(subyear); return(saved != null); } }
private void SetStructure(DbHelper.Structure sHelper, CustomPrincipal user) { var programs = sHelper.ListPrograms(user.SchoolId); if (!programs.Any()) { tbEmptyProgramListMsg.Visible = true; } programs.ForEach(p => { var litem = new ListItem() { Text = " " + p.Name, Value = p.Id.ToString() }; var pbs = p.ProgramBatches.FirstOrDefault(x => x.BatchId == BatchId); if (pbs != null) { litem.Value += "_" + pbs.Id; litem.Selected = !(pbs.Void ?? false); } else { litem.Value += "_0"; litem.Selected = false; } CheckBoxList1.Items.Add(litem); }); }
private void LoadData(int schoolId) { var acaId = AcademicYearId; var sesId = SessionId; //using (var pbHelper = new DbHelper.AcademicPlacement()) using (var helper = new DbHelper.Structure()) { int sessionId = SessionId; int academicYearId = AcademicYearId; helper.ListPrograms(schoolId).ForEach(p => { #region PROGRAM Uc init var puc = (UserControls.ProgramItemUc) Page.LoadControl("~/Views/Academy/ClassAssign/UserControls/ProgramItemUc.ascx"); puc.SetData(p.Id, p.Name, false, acaId, sesId); puc.ID = "programUc_" + p.Id; #endregion var years = p.Year.Where(x => !(x.Void ?? false)).OrderBy(x => x.Position) .ThenBy(x => x.Id).ToList(); if (puc.SetYears(years)) { pnlProgramListing.Controls.Add(puc); } }); } }
protected void btnSave_Click(object sender, EventArgs e) { bool isValid = true; if (string.IsNullOrEmpty(txtName.Text)) { isValid = false; valiTxtName.Visible = true; } if (string.IsNullOrEmpty(txtPosition.Text)) { isValid = false; valiPostion.Visible = true; } if (cmbYear.SelectedValue == "" || cmbYear.SelectedValue == "0") { isValid = false; valiCmbYear.Visible = true; } if (isValid) { var subYear = new Academic.DbEntities.Structure.SubYear() { Name = txtName.Text , Description = txtDescription.Text , Position = Convert.ToInt32(txtPosition.Text) , YearId = Convert.ToInt32(cmbYear.SelectedValue) }; if (cmbParent.SelectedValue != "" && cmbParent.SelectedValue != "0") { subYear.ParentId = Convert.ToInt32(cmbParent.SelectedValue); } using (var helper = new DbHelper.Structure()) { var saved = helper.AddOrUpdateSubYear(subYear); if (saved != null) { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs); } ClearCreateTextBoxes(); } else { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs); } } } } }
protected void btnSaveYear_Click(object sender, EventArgs e) { bool isvalid = true; if (string.IsNullOrEmpty(txtName.Text)) { isvalid = false; valiTxtName.Visible = true; } if (cmbProgram.SelectedValue == "" || cmbProgram.SelectedValue == "0") { isvalid = false; valiProgram.Visible = true; } if (string.IsNullOrEmpty(txtPosition.Text)) { isvalid = false; valitxtPosition.Visible = true; } if (isvalid) { var year = new Academic.DbEntities.Structure.Year() { Name = txtName.Text , Position = Convert.ToInt32(txtPosition.Text) , ProgramId = Convert.ToInt32(cmbProgram.SelectedValue) , Description = txtDescription.Text , }; using (var helper = new DbHelper.Structure()) { var saved = helper.AddOrUpdateYear(year); if (saved != null) { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs); } ClearCreateTextBoxes(); } else { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs); } } } } //if (OnSaveClicked != null) //{ // OnSaveClicked(this,EventArgs.Empty); //} }
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); } } }
protected void btnSaveProgram_Click(object sender, EventArgs e) { bool isValid = true; if (string.IsNullOrEmpty(txtName.Text)) { isValid = false; valiTxtName.Visible = true; } //if (cmbFaculty.SelectedValue == "" || cmbFaculty.SelectedValue == "0") //{ // isValid = false; // valiFaculty.Visible = true; //} var user = Page.User as CustomPrincipal; if (user != null) { if (isValid) { //save var prog = new Academic.DbEntities.Structure.Program() { Name = txtName.Text , SchoolId = user.SchoolId//Convert.ToInt32(cmbFaculty.SelectedValue) , Description = txtDescription.Text }; using (var helper = new DbHelper.Structure()) { var saved = helper.AddOrUpdateProgram(prog); if (saved != null) { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs); } ClearCreateTextBoxes(); } else { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs); } } } } } }
protected void Page_Load(object sender, EventArgs e) { CategoryDropDownList1.CategorySelected += CategoryDropDownList1_CategorySelected; var user = Page.User as CustomPrincipal; if (user != null) { if (!IsPostBack) { var year = Request.QueryString["yId"]; var subyear = Request.QueryString["sId"]; if (year != null && subyear != null) { try { var y = Convert.ToInt32(year); var s = Convert.ToInt32(subyear); YearId = y; SubYearId = s; using (var helper = new DbHelper.Structure()) { //var dir = helper.GetSructureDirectory(y, s); var sub = helper.GetSubYear(s); var dir = sub.Year.Program.Name + " / " + sub.Year.Name + " / " + sub.Name; ProgramId = sub.Year.ProgramId; lblHeading.Text = "Assgin Courses to : " + (dir); LoadSiteMap(dir, year, subyear); } } catch { Response.Redirect("~/Views/Structure/"); } } else { Response.Redirect("~/Views/Structure/"); } hidSchoolId.Value = user.SchoolId.ToString(); //ViewState["SelectedCourses"] = new List<Academic.ViewModel.Subject.Subject>(); //ViewState["SavedCourses"] = new List<Academic.ViewModel.Subject.Subject>(); LoadAssignedList(); } } }
private void DeleteSubYear(int subYearId) { using (var helper = new DbHelper.Structure()) { var deleted = helper.DeleteSubYear(subYearId); if (deleted) { Response.Redirect("~/Views/Structure/?edit=1", false); } else { lblError.Visible = true; } } }
bool SaveYear() { using (var helper = new DbHelper.Structure()) { var year = new Academic.DbEntities.Structure.Year() { Name = txtName.Text , Description = txtDescription.Text , Id = this.StructureId , ProgramId = ParentId , Position = Convert.ToInt32(string.IsNullOrEmpty(txtPosition.Text) ? "0" : txtPosition.Text) }; var sems = new List <Academic.DbEntities.Structure.SubYear>(); sems.Add(new Academic.DbEntities.Structure.SubYear() { Id = Sem1Id, Name = txtSem1Name.Text, Position = 1, Void = false, YearId = StructureId, }); sems.Add(new Academic.DbEntities.Structure.SubYear() { Id = Sem2Id, Name = txtSem2Name.Text, Position = 2, Void = false, YearId = StructureId, }); if (StructureId == 0) { var date = DateTime.Now; year.CreatedDate = date; sems[0].CreatedDate = date; sems[1].CreatedDate = date; } var saved = helper.AddOrUpdateYear(year, sems); return(saved != null); } }
// // Note :: ├ ==>1 , └ ==> 2 . ┌ ==> 3 , │ ==> 4 , empty ==> 0 public void LoadStructure1(int schoolId, List <Academic.ViewModel.Batch.BatchViewModel> progList) { if (progList != null) { using (var batchHelper = new DbHelper.Batch()) using (var helper = new DbHelper.Structure()) { var progBatchList = batchHelper.GetProgramBatchList(BatchId); var programs = helper.ListPrograms(schoolId); var ip = 1; programs.ForEach(p => { var puc = (LabelAndCheckBoxUC) Page.LoadControl( "~/Views/Structure/All/UserControls/StructureView/LabelAndCheckBoxUC.ascx"); var pbId = 0; if (progBatchList != null) { var saved = progBatchList.FirstOrDefault(x => x.ProgramId == p.Id); if (saved != null) { pbId = saved.Id; progList.Add(new BatchViewModel() { ProgramBatchId = saved.Id , ProgramId = saved.ProgramId , Check = true }); puc.Check = true; } } puc.SetName(p.Id, p.Name, pbId); //puc.CheckedChange += puc_CheckedChange; pnlTree.Controls.Add(puc); ip++; }); } } }
public void LoadStructure(int schoolId) { var batchId = BatchId; var user = Page.User as CustomPrincipal; if (user != null) { using (var aHelper = new DbHelper.AcademicYear()) using (var helper = new DbHelper.Structure()) { //var academicYears = aHelper.ListNotCompleteAcademicYear(user.SchoolId); //if (academicYears.Any()) //{ // ddlAcademicYear.DataValueField = "Id"; // ddlAcademicYear.DataTextField = "Name"; // ddlAcademicYear.DataSource = academicYears; // ddlAcademicYear.DataBind(); //} var programs = helper.ListPrograms(schoolId); programs.ForEach(p => { var litem = new ListItem() { Text = " " + p.Name, Value = p.Id.ToString() }; var pbs = p.ProgramBatches.FirstOrDefault(x => x.BatchId == BatchId); if (pbs != null) { litem.Value += "_" + pbs.Id; litem.Selected = !(pbs.Void ?? false); } else { litem.Value += "_0"; litem.Selected = false; } CheckBoxList1.Items.Add(litem); }); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); using (var context = new AcademicContext()) { //var d = context.Level.Where(x => x.SchoolId == InitialValues.CustomSession["SchoolId"]). ToList(); //cmbLevel.DataSource = d; //cmbLevel.DataBind(); } var helper = new DbHelper.Structure(); cmbLevel.Width = 100; //cmbLevel.DataSource = helper.GetLevels(InitialValues.CustomSession["SchoolId"]); cmbLevel.DataMember = "Id"; cmbLevel.DataTextField = "Name"; cmbLevel.DataValueField = "Id"; cmbLevel.DataBind(); } }
void CustomDialog1_ItemClick(object sender, IdAndNameEventArgs e) { //copy the year and sub-years from the choosen program to this program if (e.Id == 0) { CustomDialog1.CloseDialog(); return; } using (var helper = new DbHelper.Structure()) { var copied = helper.CopyYearsAndSubyears(e.Id, ParentId); if (copied) { Response.Redirect("~/Views/Structure/?edit=1"); } else { lblCopyError.Visible = true; CustomDialog1.CloseDialog(); } } }
protected void Button1_Click(object sender, EventArgs e) { if (cmbProgram.SelectedValue == "") { valiProg.IsValid = false; } if (IsValid) { //save year using (var helper = new DbHelper.Structure()) { var section = new Academic.DbEntities.Structure.SubYear() { Name = txtName.Text , YearId = Convert.ToInt32(cmbProgram.SelectedValue) , }; var saved = helper.AddOrUpdateSubYear(section); if (saved != null) { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs); } } else { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs); } } //Response.Write("Error while saving."); } } }
//list mode private void LoadListMode(int schoolId) { //var pId = Request.QueryString["pId"]; //var edit = Edit == "1"; using (var helper = new DbHelper.Structure()) { helper.ListPrograms(schoolId).ForEach(p => { #region Program data populate code var puc = (YearInfoUc)Page .LoadControl("~/Views/Structure/YearInfoUc.ascx"); puc.LoadProgram(p); pnlListing.Controls.Add(puc); pnlListing.Controls.Add(new Literal() { Text = "<br />" }); #endregion }); } }
//bool SaveLevel(int schoolId) //{ // using (var helper = new DbHelper.Structure()) // { // var level = new Academic.DbEntities.Structure.Level() // { // Name = txtName.Text // , // Description = txtDescription.Text // , // Id = this.StructureId // , // SchoolId = schoolId // }; // if (StructureId == 0) // level.CreatedDate = DateTime.Now; // var saved = helper.AddOrUpdateLevel(level); // return saved != null; // } //} //bool SaveFaculty() //{ // using (var helper = new DbHelper.Structure()) // { // var fac = new Academic.DbEntities.Structure.Faculty() // { // Name = txtName.Text // , // Description = txtDescription.Text // , // Id = this.StructureId // , // LevelId = ParentId // }; // if (StructureId == 0) // fac.CreatedDate = DateTime.Now; // var saved = helper.AddOrUpdateFaculty(fac); // return saved != null; // } //} bool SavePogram(int schoolId) { using (var helper = new DbHelper.Structure()) { var pro = new Academic.DbEntities.Structure.Program() { Name = txtName.Text , Description = txtDescription.Text , Id = StructureId , SchoolId = schoolId }; if (StructureId == 0) { pro.CreatedDate = DateTime.Now; } var saved = helper.AddOrUpdateProgram(pro); return(saved != null); } }
List <IdAndName> GetCourse() { var subId = Request.QueryString["SubId"]; var fromCls = Request.QueryString["from"]; var yId = Request.QueryString["yId"]; var sId = Request.QueryString["sId"]; using (var helper = new DbHelper.Subject()) { var list = new List <IdAndName>(); var sub = helper.Find(Convert.ToInt32(subId)); // if (SiteMap.CurrentNode != null) // { list.Add(new IdAndName() { Name = "Home", //SiteMap.RootNode.Title, Value = "~/", //SiteMap.RootNode.Url, Void = true }); if (sId != null && yId != null) { //lnkEdit.NavigateUrl += "&yId=" + yId + "&sId=" + sId; list.Add(new IdAndName() { Name = "Manage Programs", Value = "~/Views/Structure/", Void = true }); using (var strHelper = new DbHelper.Structure()) { list.Add(new IdAndName() { Name = strHelper.GetSructureDirectory(Convert.ToInt32(yId), Convert.ToInt32(sId)), Value = "~/Views/Structure/CourseListing.aspx?yId=" + yId + "&sId=" + sId, Void = true }); } list.Add(new IdAndName() { Name = sub.FullName }); } else if (fromCls != null) { //lnkEdit.NavigateUrl += "&frmDetailView=" + fromCls; list.Add(new IdAndName() { Name = "Courses", //SiteMap.CurrentNode.ParentNode.Title, Value = "~/Views/Course/Default.aspx", //SiteMap.CurrentNode.ParentNode.Url, Void = true }); list.Add(new IdAndName() { Name = sub.FullName, Value = "~/Views/Course/CourseDetail.aspx?cId=" + sub.Id, Void = true }); list.Add(new IdAndName() { Name = "View" }); } else { list.Add(new IdAndName() { Name = sub.FullName, Value = "~/Views/Course/Section/?SubId=" + subId, //"~/Views/Course/CourseDetail.aspx?cId=" + sub.Id Void = true }); } //} return(list); } }
//compress mode private void LoadCompressMode(int schoolId) { var pId = Request.QueryString["pId"]; var edit = Edit == "1"; using (var helper = new DbHelper.Structure()) { helper.ListPrograms(schoolId).ForEach(p => { #region Program data populate code var expand = p.Id.ToString() == pId; var puc = (ListUC)Page .LoadControl("~/Views/Structure/All/UserControls/ListUC.ascx") ; puc.SetName(p.Id, p.Name , "~/Views/Structure/StructureCreate.aspx?strId=" + p.Id + "&progId=" + p.Id + "&strTyp=pro" , edit , "~/Views/Structure/StructureCreate.aspx?pId=" + p.Id + "&progId=" + p.Id + "&strTyp=yr", "Add Year" , expand ); pnlListing.Controls.Add(puc); #endregion p.Year.Where(x => !(x.Void ?? false)) .OrderBy(x => x.Position) .ToList() //helper.GetYears(p.Id) .ForEach(y => { var subyears = y.SubYears.Where(x => !(x.Void ?? false) && (x.ParentId ?? 0) == 0) .OrderBy(or => or.Position) .ToList(); #region Unused code //helper.GetSubYears(y.Id, true); //if (!subyears.Any()) //{ // //display course info in this year since no subyear // //course info is only in subyearUC // var yuc = (ListSubYearUC)Page // .LoadControl("~/Views/Structure/All/UserControls/ListSubYearUC.ascx"); // //yuc.CourseClicked+=subYear_CourseClicked; // var pbname = ""; // int pbId = 0; // var pb = // y.RunningClasses.FirstOrDefault(x => (x.SubYearId ?? 0) == 0 && (x.IsActive ?? true) // && x.AcademicYear.IsActive // && !(x.Completed ?? false)); // if (pb != null) // { // if (pb.ProgramBatchId != null) // { // pbname = pb.ProgramBatch.NameFromBatch; // pbId = pb.ProgramBatchId ?? 0; // } // } // yuc.SetName(y.Id, 0, y.Name // , "~/Views/Structure/StructureCreate.aspx?strId=" + y.Id + "&strTyp=yr" // , y.SubjectStructures.Count(x => !(x.Void ?? false) && (x.SubYearId ?? 0) == 0) // , pbname, pbId // , edit // , "~/Views/Structure/StructureCreate.aspx?pId=" + y.Id + "&strTyp=syr", "Add Sub-Year" // ); // puc.AddControl(yuc); //} //else #endregion #region Year code var yuc = (ListYearUC)Page .LoadControl("~/Views/Structure/All/UserControls/ListYearUC.ascx"); yuc.SetName(y.Id, y.Name , "~/Views/Structure/StructureCreate.aspx?strId=" + y.Id + "&progId=" + p.Id + "&strTyp=yr" , edit //, "~/Views/Structure/StructureCreate.aspx?pId=" + y.Id + "&progId=" + p.Id + "&strTyp=syr", "Add Sub-Year" ); puc.AddControl(yuc); #endregion //get subyears subyears.ForEach(s => { #region SubYears populate code var pbname = ""; int pbId = 0; var pb = s.RunningClasses.FirstOrDefault(x => (x.IsActive ?? true) && x.Session.IsActive && !(x.Completed ?? false)) ; if (pb != null) { if (pb.ProgramBatchId != null) { pbname = pb.ProgramBatch.NameFromBatch; pbId = pb.ProgramBatchId ?? 0; } } var suc = (ListSubYearUC)Page .LoadControl("~/Views/Structure/All/UserControls/ListSubYearUC.ascx"); //suc.CourseClicked += subYear_CourseClicked; suc.SetName(y.Id, s.Id, s.Name , "~/Views/Structure/StructureCreate.aspx?strId=" + s.Id + "&progId=" + p.Id + "&strTyp=syr" , s.SubjectStructures.Count(x => !(x.Void ?? false)) , pbname, pbId , edit); yuc.AddControl(suc); #endregion }); }); }); #region unused code (Level code previous) //levels.ForEach(l => //{ // var luc = (ListLevelUC)Page // .LoadControl("~/Views/Structure/All/UserControls/ListLevelUC.ascx"); // luc.SetName(l.Id, l.Name, "~/Views/Structure/StructureCreate.aspx?strId=" + l.Id + "&strTyp=lev" // , edit // , "~/Views/Structure/StructureCreate.aspx?pId=" + l.Id + "&strTyp=fac", "Add Faculty" // ); // pnlListing.Controls.Add(luc); // var faculties = helper.GetFaculties(l.Id); // if (!faculties.Any()) // { // var fuc = (ListUC)Page // .LoadControl("~/Views/Structure/All/UserControls/ListUC.ascx"); // luc.AddControl(fuc); // } // else // { // faculties.ForEach(f => // { // var fuc = (ListUC)Page // .LoadControl("~/Views/Structure/All/UserControls/ListUC.ascx"); // fuc.SetName(f.Id, "●" + f.Name // , "~/Views/Structure/StructureCreate.aspx?strId=" + f.Id + "&strTyp=fac" // , edit // , "~/Views/Structure/StructureCreate.aspx?pId=" + f.Id + "&strTyp=pro", "Add Program"); // luc.AddControl(fuc); // }); // } //}); #endregion } }
//public event EventHandler<MessageEventArgs> SaveClickedEvent; protected void Page_Load(object sender, EventArgs e) { lblError.Visible = false; CustomDialog1.ItemClick += CustomDialog1_ItemClick; if (!IsPostBack) { var user = Page.User as CustomPrincipal; if (user != null) { try { var type = Request.QueryString["strTyp"]; if (type == null) { Response.Redirect("~/Views/Structure/", true); } else { StructureType = type; LoadStructureType(); var strId = Request.QueryString["strId"]; var pId = Request.QueryString["pId"]; var progId = Request.QueryString["progId"]; if (progId != null) { hidProgramId.Value = progId; } if (strId != null) { StructureId = Convert.ToInt32(strId); LoadStructure(); } else if (pId != null)// there must be parent id if (structure id is not given) { var parentId = Convert.ToInt32(pId); ParentId = parentId; //if year creation is choosen then check if there are any other year in this program //if no year then give to choose the program from which year and subyear can be imported if (type == "yr") { //EnableSemesterValidation(); //tblSubyear.Visible = true; //reqValiSubYear1.ValidationGroup = "save"; //reqValiSubYear2.ValidationGroup = "save"; using (var helper = new DbHelper.Structure()) { var prog = helper.GetProgram(parentId); if (prog != null) { //var cnt = prog.Year.Count; if (!(prog.Year.Any(x => !(x.Void ?? false)))) { //show dialog to choose another program and var programs = helper.GetPrograms(user.SchoolId); var thisone = programs.Find(x => x.Id == parentId); if (thisone != null) { programs.Remove(thisone); } //there has to be another program to choose so check for it if (programs.Count > 0) { //show dialog // and list all the programs to choose var items = programs.Select(x => new IdAndName() { Name = "● " + x.Name, Id = x.Id }).ToList(); items.Add(new IdAndName() { Id = 0, Name = "□ I would like to add manually" }); CustomDialog1.SetValues("Copy all years and semesters from...", items, "", "cancel"); CustomDialog1.OpenDialog(); } } } } } } } } catch { Response.Redirect("~/Views/Structure/"); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var year = Request.QueryString["yId"]; var subyear = Request.QueryString["sId"]; if (year != null && subyear != null) { try { var y = Convert.ToInt32(year.ToString()); var s = Convert.ToInt32(subyear.ToString()); using (var helper = new DbHelper.Structure()) { var sub = helper.GetSubYear(s); //var dir = helper.GetSructureDirectory(y, s); var dir = sub.Year.Program.Name + " / " + sub.Year.Name + " / " + sub.Name; CourseListUC.SetProgramDirectory(dir); var editQuery = Request.QueryString["edit"]; var edit = (editQuery ?? "0").ToString(); 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 + "?pId=" + sub.Year.ProgramId , Void = true }, new IdAndName() { Name = dir } }; SiteMapUc.SetData(list); } CourseListUC.LoadCourseList(edit, y, s); } } catch { Response.Redirect("~/Views/Structure/All/Master/List.aspx"); } } else { Response.Redirect("~/Views/Structure/All/Master/List.aspx"); } /*var yearId = ViewState["yearId"]; * var subyearId = ViewState["subYearId"]; * * //viewsta * if (yearId == null || subyearId == null) * { * Response.Redirect("List.aspx"); * } * else * { * var y = Convert.ToInt32(yearId.ToString()); * var s = Convert.ToInt32(subyearId.ToString()); * using (var helper = new DbHelper.Structure()) * { * var dir = helper.GetSructureDirectory(y, s); * CourseListUC.SetProgramDirectory(dir); * } * CourseListUC.LoadCourseList(y, s); * }*/ } }
public void Grouping(int yearId) { //protected void Page_Load(object sender, EventArgs e) //{ cmbParent.Items.Clear(); using (var helper = new DbHelper.Structure()) { var yea = helper.ListSubYears(yearId, true, true); var s = yea.GroupBy(x => x.ParentId); foreach (var v in s) { //var x=v.GetEnumerator(); //x.Current.Name var y = yea.Where(x => x.ParentId == v.Key); foreach (var i in y) { ListItem item = new ListItem(i.Name, i.Id.ToString()); var grp = yea.FirstOrDefault(x => x.Id == i.ParentId); if (grp != null) { item.Attributes["OptionGroup"] = grp.Name; } cmbParent.Items.Add(item); } } } //ListItem item1 = new ListItem("Camel", "1"); // item1.Attributes["OptionGroup"] = "Mammals"; // ListItem item2 = new ListItem("Lion", "2"); // item2.Attributes["OptionGroup"] = "Mammals"; // ListItem item3 = new ListItem("Whale", "3"); // item3.Attributes["OptionGroup"] = "Mammals"; // ListItem item4 = new ListItem("Walrus", "4"); // item4.Attributes["OptionGroup"] = "Mammals"; // ListItem item5 = new ListItem("Velociraptor", "5"); // item5.Attributes["OptionGroup"] = "Dinosaurs"; // ListItem item6 = new ListItem("Allosaurus", "6"); // item6.Attributes["OptionGroup"] = "Dinosaurs"; // ListItem item7 = new ListItem("Triceratops", "7"); // item7.Attributes["OptionGroup"] = "Dinosaurs"; // ListItem item8 = new ListItem("Stegosaurus", "8"); // item8.Attributes["OptionGroup"] = "Dinosaurs"; // ListItem item9 = new ListItem("Tyrannosaurus", "9"); // item9.Attributes["OptionGroup"] = "Dinosaurs"; // ddlItems.Items.Add(item1); // ddlItems.Items.Add(item2); // ddlItems.Items.Add(item3); // ddlItems.Items.Add(item4); // ddlItems.Items.Add(item5); // ddlItems.Items.Add(item6); // ddlItems.Items.Add(item7); // ddlItems.Items.Add(item8); // ddlItems.Items.Add(item9); //} }
private void LoadStructure() { using (var helper = new DbHelper.Structure()) { switch (StructureType) { //case "lev": // var level = helper.GetLevel(StructureId); // if (level != null) // { // txtName.Text = level.Name; // txtDescription.Text = level.Description; // ParentId = level.SchoolId; // } // break; //case "fac": // //var fac = helper.GetFaculty(StructureId); // //if (fac != null) // //{ // // txtName.Text = fac.Name; // // txtDescription.Text = fac.Description; // // ParentId = fac.LevelId; // //} // break; case "pro": var pro = helper.GetProgram(StructureId); if (pro != null) { txtName.Text = pro.Name; txtDescription.Text = pro.Description; ParentId = pro.SchoolId; } break; case "yr": var year = helper.GetYear(StructureId); tblSubyear.Visible = true; if (year != null) { txtName.Text = year.Name; txtDescription.Text = year.Description; ParentId = year.ProgramId; position_row.Visible = true; txtPosition.Text = year.Position.ToString(); var sems = year.SubYears.Where(x => !(x.Void ?? false)).ToList(); if (sems.Count >= 2) { txtSem1Name.Text = sems[0].Name; txtSem2Name.Text = sems[1].Name; hidSem1Id.Value = sems[0].Id.ToString(); hidSem2Id.Value = sems[1].Id.ToString(); } } break; case "syr": var syear = helper.GetSubYear(StructureId); if (syear != null) { txtName.Text = syear.Name; txtDescription.Text = syear.Description; ParentId = syear.YearId ?? 0; position_row.Visible = true; txtPosition.Text = syear.Position.ToString(); } break; } } }
private void LoadCourse(int courseId) { var user = Page.User as CustomPrincipal; var edit = hidEdit.Value; if (user != null) { using (var cHelper = new DbHelper.Classes()) using (var strHelper = new DbHelper.Structure()) using (var helper = new DbHelper.Subject()) { var sub = helper.Find(courseId); if (sub != null) { LoadSitemap(strHelper, sub); txtSubjectName.Text = sub.FullName; //uncomment ListOfSectionsInCourseUC1.CourseId = Id; lblPageTitle.Text = sub.FullName; var courseStatus = cHelper.GetCourseClassesAvailabilityForUser(user.Id, sub.Id); var stat = courseStatus.Split(new[] { ',' }); if (stat.Length >= 2) { var fromCls = Request.QueryString["from"]; var from = ""; if (fromCls == "detail") { from = "&from=detail"; } else { from = "&from=view"; } lnkMyClasses.Visible = stat[1].Equals(DbHelper.StaticValues.Roles.Teacher); lnkMyClasses.NavigateUrl = "~/Views/Class/MyClasses.aspx?subId=" + courseId + from; } switch (stat[0]) { case "current": if (stat.Length >= 3) { if (!(user.IsInRole("teacher") || user.IsInRole("manager"))) { lnkEnroll.Visible = stat[2] != "0"; lnkEnroll.NavigateUrl = "~/Views/Class/SelfEnrolment.aspx?ccId=" + stat[2]; lnkEnroll.Text = "Remove Enrollment"; } else { lnkEnroll.Visible = false; } //btnEnroll.Visible = stat[2] != "0"; //btnEnroll. } imgJoinInfo.Visible = true; imgJoinInfo.ImageUrl = "~/Content/Icons/Start/active_icon_10px.png"; break; case "complete": imgJoinInfo.Visible = true; if (!(user.IsInRole("teacher") || user.IsInRole("manager"))) { imgJoinInfo.ImageUrl = "~/Content/Icons/Diploma/diploma_16px.png"; } else { imgJoinInfo.ImageUrl = "~/Content/Icons/Stop/Stop_10px.png"; } break; case "open": //if (!(user.IsInRole("teacher") || user.IsInRole("manager"))) //{ // btnEnroll.Visible = true; // SetEnrollDialog(); //} break; case "close": break; default: break; } //lblClassInformation.Text = cHelper.GetCourseClassesAvailabilityForUser(user.Id, sub.Id); } //CourseDetailUc1. } } }
void LoadSitemap(DbHelper.Structure strHelper, Academic.DbEntities.Subjects.Subject sub) { var fromCls = Request.QueryString["from"]; var yId = Request.QueryString["yId"]; var sId = Request.QueryString["sId"]; if (SiteMap.CurrentNode != null) { var list = new List <IdAndName>() { new IdAndName() { Name = SiteMap.RootNode.Title , Value = SiteMap.RootNode.Url , Void = true }, }; if (sId != null && yId != null) { //lnkEdit.NavigateUrl += "&yId=" + yId + "&sId=" + sId; list.Add(new IdAndName() { Name = "Manage Programs" , Value = "~/Views/Structure/" , Void = true }); list.Add(new IdAndName() { Name = strHelper.GetSructureDirectory(Convert.ToInt32(yId), Convert.ToInt32(sId)) , Value = "~/Views/Structure/CourseListing.aspx?yId=" + yId + "&sId=" + sId , Void = true }); list.Add(new IdAndName() { Name = sub.FullName }); } else if (fromCls != null) { //lnkEdit.NavigateUrl += "&frmDetailView=" + fromCls; list.Add(new IdAndName() { Name = SiteMap.CurrentNode.ParentNode.Title , Value = SiteMap.CurrentNode.ParentNode.Url , Void = true }); list.Add(new IdAndName() { Name = sub.FullName , Value = "~/Views/Course/CourseDetail.aspx?cId=" + sub.Id , Void = true }); list.Add(new IdAndName() { Name = "View" }); } else { list.Add(new IdAndName() { Name = sub.FullName , //Value = "~/Views/Course/CourseDetail.aspx?cId=" + sub.Id //, //Void = true }); } SiteMapUc.SetData(list); } }
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("~/"); } } }
private void LoadStructure(int schoolId) { // key: program, Value: list of programBatch var alreadySelected = Session["AlreadySelectedProgramBatches"] as Dictionary <int, List <int> >; if (alreadySelected != null) { using (var pbHelper = new DbHelper.AcademicPlacement()) using (var helper = new DbHelper.Structure()) { int sessionId = SessionId; int academicYearId = AcademicYearId; var anyPrograms = false; var anyYears = false; var programs = helper.ListPrograms(schoolId); //var fuc = (ListFacultyUC)Page // .LoadControl("~/Views/Academy/ProgramSelection/ListFacultyUC.ascx"); //fuc.ID = "facultyControl" + f.Id; //fuc.ClientIDMode = ClientIDMode.Static; if (programs.Any()) { anyPrograms = true; } programs.ForEach(p => { //var puc = (ListUC)Page // .LoadControl("~/Views/Structure/All/UserControls/ListUC.ascx") // ; var years = helper.GetYears(p.Id); var puc = (ProgramCheckBoxAndLabel) Page.LoadControl("~/Views/Academy/ProgramSelection/ProgramCheckBoxAndLabel.ascx"); if (years.Any()) { puc.SetName(p.Id, p.Name, ""); puc.ID = "programControl" + p.Id; puc.ClientIDMode = ClientIDMode.Static; pnlProgramListing.Controls.Add(puc); //add these programs to the dictionary key values if (!IsPostBack) { var key = alreadySelected.Keys.FirstOrDefault(q => q == p.Id); //if (alreadySelected[p.Id] == null) if (key <= 0) { alreadySelected[p.Id] = new List <int>(); } } } years.ForEach(y => { var subyears = helper.GetSubYears(y.Id, true); if (!subyears.Any()) { #region No subYears if (sessionId <= 0) { var yuc = (YearCheckBoxAndLabel) Page.LoadControl( "~/Views/Academy/ProgramSelection/YearCheckBoxAndLabel.ascx"); //yuc.CourseClicked+=subYear_CourseClicked; yuc.SetIds(p.Id, y.Id, 0); yuc.SetName(p.Name, y.Name, "");//y.Id, y.Name, p.Id, ""); yuc.ClientIDMode = ClientIDMode.Static; yuc.ID = "yearControl" + y.Id; puc.AddControl(yuc); anyYears = true; yuc.SetImageUrl(); yuc.ImageVisibility = true; yuc.BatchSelectClicked += yuc_BatchSelectClicked; //work remain: //get programbatchId for this year and then add it to the // alreadySelected session list // also populate the selected batch for this year // this task is to be done for subyears too //Get ProgramBatchId for this year var rcls = pbHelper.GetRunningClassInAcademicYear(academicYearId, y.Id, sessionId, 0); if (rcls != null) { if (!(rcls.Void ?? false)) { if (!alreadySelected[p.Id].Contains(rcls.ProgramBatchId ?? 0) && !IsPostBack) { alreadySelected[p.Id].Add(rcls.ProgramBatchId ?? 0); } //Now display yuc.SetSelectedBatch(rcls.ProgramBatchId ?? 0, rcls.ProgramBatch.NameFromBatch, rcls.Id); yuc.Checked = true; } else { //this is done to unvoid the previously voided data.. // so that no duplicate data(one with void and next with no-void) //is made in running class yuc.SetSelectedBatch(0, "", rcls.Id); } } } #endregion //display course info in this year since no subyear //course info is only in subyearUC //var yuc = (ListSubYearUC)Page // .LoadControl("~/Views/Structure/All/UserControls/ListSubYearUC.ascx"); //var yuc = (YearCheckBoxAndLabel) // Page.LoadControl( // "~/Views/Academy/ProgramSelection/YearCheckBoxAndLabel.ascx"); } else { if (sessionId > 0) { #region There are subYears anyYears = true; var yuc = (YearCheckBoxAndLabel) Page.LoadControl( "~/Views/Academy/ProgramSelection/YearCheckBoxAndLabel.ascx"); yuc.ClientIDMode = ClientIDMode.Static; yuc.ID = "yearControl" + y.Id; yuc.SetIds(p.Id, y.Id, 0); yuc.SetName(p.Name, y.Name, ""); yuc.ImageVisibility = false; yuc.BatchSelectClicked += yuc_BatchSelectClicked; puc.AddControl(yuc); //Get ProgramBatchId for this year //var pbatch = pbHelper.GetProgramBatchInAcademicYear(academicYearId, // y.Id, sessionId, 0); //if (pbatch != null) //{ // alreadySelected[p.Id].Add(pbatch.Id); // //Now display // yuc.SetSelectedBatch(pbatch.Id, pbatch.NameFromBatch); //} //get subyears subyears.ForEach(s => { //rdList.Items.Add(new ListItem(s.Name, s.Id.ToString())); var suc = (ListSubYearUC)Page .LoadControl("~/Views/Academy/ProgramSelection/ListSubYearUC.ascx"); //suc.CourseClicked += subYear_CourseClicked; suc.ClientIDMode = ClientIDMode.Static; suc.ID = "subyearControl" + s.Id; suc.SetIds(p.Id, y.Id, s.Id); suc.SetName(p.Name, y.Name, s.Name); //suc.SetName(y.Id, s.Id, s.Name, p.Id); suc.BatchSelectClicked += suc_BatchSelectClicked; yuc.AddControl(suc); //Get ProgramBatchId for this subyear var rcls = pbHelper.GetRunningClassInAcademicYear(academicYearId, y.Id, sessionId, s.Id); if (rcls != null) { if (!(rcls.Void ?? false)) { if (!alreadySelected[p.Id].Contains(rcls.ProgramBatchId ?? 0) && !IsPostBack) { alreadySelected[p.Id].Add(rcls.ProgramBatchId ?? 0); } //Now display suc.SetSelectedBatch(rcls.ProgramBatchId ?? 0, rcls.ProgramBatch == null ? "" : rcls.ProgramBatch.NameFromBatch, rcls.Id); suc.Checked = true; yuc.Checked = true; } else { //runnning class is void //this is done to unvoid the previously voided data.. // so that no duplicate data(one with void and next with no-void) //is made in running class suc.SetSelectedBatch(0, "", rcls.Id); } } }); #endregion //yuc.AddControl(rdList); } } }); }); //if (anyPrograms && anyYears) //{ // //years xa bhane matra faculty print garne // fuc.SetName(f.Id, f.Name, ""); // luc.AddControl(fuc); //} //helper.GetLevels(schoolId).ForEach(l => //{ // var luc = (ListLevelUC)Page // .LoadControl("~/Views/Academy/ProgramSelection/ListLevelUC.ascx"); // luc.SetName(l.Id, l.Name, ""); // luc.ID = "levelControl" + l.Id; // luc.ClientIDMode = ClientIDMode.Static; // var faculties = helper.GetFaculties(l.Id); // var anyFaculty = false; // if (faculties.Any()) // { // anyFaculty = true; // faculties.ForEach(f => // { // }); // } // if (anyFaculty) // { // pnlProgramListing.Controls.Add(luc); // } //}); } } }
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); } } }