Exemple #1
0
        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);
                    }
                });
            }
        }
Exemple #3
0
        //  // 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++;
                        });
                    }
            }
        }
Exemple #4
0
        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);
                        });
                    }
            }
        }
Exemple #5
0
        //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
                });
            }
        }
Exemple #6
0
        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);
                        //    }
                        //});
                    }
            }
        }
Exemple #7
0
        //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
            }
        }