예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            context                 = new serverDBEntities();
            departmentBehavior      = new Department(context);
            currentScheduleBehavior = new CurrentSchedule(context);
            groupBehavior           = new Group(context);
            weekBehavior            = new Week(context);
            semesterBehavior        = new Semester(context);

            List <Department> departments = departmentBehavior.GetList();

            List <Week> weeksForSemester   = weekBehavior.GetListForSemester(semesterBehavior.GetActiveSemester());
            var         weekBoxItemsSource = from week in weeksForSemester
                                             select new { WeekID = week.ID, DateSpan = week.START_DATE.Date.ToShortDateString() + "  -  " + week.END_DATE.Date.ToShortDateString() };

            foreach (Department department in departments)
            {
                LinkButton label = new LinkButton();
                label.Text            = department.NAME;
                label.CssClass        = "departmentLinktButton";
                label.Click          += label_Click;
                label.CommandArgument = department.ID.ToString();
                departmentsPanel.Controls.Add(label);
                departmentsButtons.Add(label);
            }

            if (!this.IsPostBack)
            {
                if (departmentsButtons.Count != 0)
                {
                    label_Click(departmentsButtons[0], new EventArgs());
                }

                DropDownList1.DataSource     = weekBoxItemsSource.ToList();
                DropDownList1.DataTextField  = "DateSpan";
                DropDownList1.DataValueField = "WeekID";
                DropDownList1.DataBind();

                Week currentWeek = weekBehavior.GetCurrentWeek();
                if (currentWeek != null)
                {
                    DropDownList1.SelectedValue = currentWeek.ID.ToString();
                }
            }

            if (treeViewGroups.SelectedNode != null)
            {
                buttonPdf.Visible     = true;
                buttonPng.Visible     = true;
                Label1.Visible        = true;
                DropDownList1.Visible = true;
            }
            else
            {
                buttonPdf.Visible     = false;
                buttonPng.Visible     = false;
                Label1.Visible        = false;
                DropDownList1.Visible = false;
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            context                 = new serverDBEntities();
            departmentBehavior      = new Department(context);
            currentScheduleBehavior = new CurrentSchedule(context);
            groupBehavior           = new Group(context);
            weekBehavior            = new Week(context);
            semesterBehavior        = new Semester(context);

            List <Department> departments = departmentBehavior.GetList();

            foreach (Department department in departments)
            {
                HtmlGenericControl listItem = createListTextItem(department.NAME, null);
                menuList.Controls.Add(listItem);
                populateTreeView(department, listItem);
            }

            if (!this.IsPostBack)
            {
                List <Week> weeksForSemester   = weekBehavior.GetListForSemester(semesterBehavior.GetActiveSemester());
                var         weekBoxItemsSource = from week in weeksForSemester
                                                 select new { WeekID = week.ID, DateSpan = week.START_DATE.Date.ToShortDateString() + "  -  " + week.END_DATE.Date.ToShortDateString() };

                DropDownList1.DataSource     = weekBoxItemsSource.ToList();
                DropDownList1.DataTextField  = "DateSpan";
                DropDownList1.DataValueField = "WeekID";
                DropDownList1.DataBind();

                Week currentWeek = weekBehavior.GetCurrentWeek();
                if (currentWeek != null)
                {
                    DropDownList1.SelectedValue = currentWeek.ID.ToString();
                }
            }

            if (Request.QueryString["group"] != null)
            {
                if (currentScheduleBehavior.HasCurrentSchedule(Int32.Parse(Request.QueryString["group"])))
                {
                    choosenGroupID        = Int32.Parse(Request.QueryString["group"]);
                    label.InnerText       = groupBehavior.GetGroupById((int)choosenGroupID).NAME;
                    DropDownList1.Visible = true;
                    buttonPdf.Visible     = true;
                    buttonPng.Visible     = true;
                }
                else
                {
                    label.InnerText  = "Brak aktualnego planu dla grupy ";
                    choosenGroupID   = Int32.Parse(Request.QueryString["group"]);
                    label.InnerText += groupBehavior.GetGroupById((int)choosenGroupID).NAME;
                }
            }
            else
            {
                choosenGroupID        = null;
                label.InnerText       = "Aby rozpocząć, wybierz grupę z menu...";
                DropDownList1.Visible = false;
                buttonPdf.Visible     = false;
                buttonPng.Visible     = false;
            }
        }