예제 #1
0
        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;
                }
            }
        }