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; } } }
//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/"); } } } }