public List<Module> GetDisabledModuleList(int lecturerID)
        {
            //gets list of disabled modules linked to a lecturer

            List<Module> listModules = null;

            SqlParameter[] paramaters = new SqlParameter[]
            {
                new SqlParameter("@LecturerID", lecturerID),
            };

            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetDisabledModuleList", CommandType.StoredProcedure, paramaters))
            {
                if (table.Rows.Count > 0)
                {
                    listModules = new List<Module>();

                    foreach (DataRow row in table.Rows)
                    {
                        Module module = new Module();
                        module.ModuleID = Convert.ToInt32(row["ModuleID"]);
                        module.ModuleCode = row["ModuleCode"].ToString();
                        module.LecturerID = Convert.ToInt32(row["LecturerID"]);
                        module.Date = Convert.ToDateTime(row["Date"]);
                        listModules.Add(module);
                    }
                }
            }

            return listModules;
        }
        protected void btnAddModule_Click(object sender, EventArgs e)
        {
            if (lstLecturers.SelectedIndex == -1)
            {
                lblLecturer.Text = "You must first select a lecturer from the box above.";
            }
            else
            {
                int lecturerID = Convert.ToInt32(lstLecturers.SelectedValue);
                int lastID = 0;

                Module newModule = new Module();
                newModule.ModuleCode = txtModuleCode.Value;
                newModule.LecturerID = lecturerID;
                newModule.Date = Convert.ToDateTime(dateSelect.Value);

                ModuleHandler moduleHandler = new ModuleHandler();

                lastID = moduleHandler.AddNewModule(newModule);
                if (lastID > 0)
                {
                    litAlert.Text = "<div class='alert alert-success'>Module added</div>";

                    Response.Redirect("AddStudents.aspx?module=" + lastID);
                }
                else
                {
                    litAlert.Text = "<div class='alert alert-danger'>Failed to add module</div>";
                }

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string htmlOutput = "";
            int moduleID = Convert.ToInt32(Request.QueryString["module"]);

            //get module name
            ModuleHandler moduleHandler = new ModuleHandler();
            Module module = new Module();
            module = moduleHandler.GetModuleDetails(Convert.ToInt32(moduleID));

            litHeader.Text = "<div class='alert alert-info'>" + module.ModuleCode + "</div>";

            StudentHandler studentHandler = new StudentHandler();
            List<Student> listStudents = studentHandler.GetStudentList(moduleID);

            //Check to make sure there is students in the system assigned to the module
            if (listStudents == null)
                litHeader.Text = "<h3>There are currently no students linked to this module</h3>";
            else
            {
                htmlOutput = "<tr><th>Student number</th><th>Firstname</th><th>Surname</th></tr>\n";
                //add modules to table as it is generated
                for (int i = 0; i < listStudents.Count; i++)
                {
                    htmlOutput += "<tr><td>" + listStudents[i].StudentNumber + "</td><td>" + listStudents[i].FirstName + "</td><td>" + listStudents[i].Surname + "</td></tr>\n";
                }
            }
            litStudentList.Text = htmlOutput;
        }
示例#4
0
        public List <MenuClass> GetCTopMenu(int userId)
        {
            DataTable        dt   = new DAL.Module().GetCTopMenu(userId);
            List <MenuClass> list = new List <MenuClass>();

            DataRow[] rows = dt.Select("ParentID=0");
            if (rows.Length > 0)
            {
                for (int i = 0; i < rows.Length; i++)
                {
                    MenuClass firstMenu = new MenuClass
                    {
                        MenuId       = Convert.ToInt32(rows[i]["PKID"].ToString()),
                        MenuName     = rows[i]["Name"].ToString(),
                        ParentID     = Convert.ToInt32(rows[i]["ParentID"].ToString()),
                        IsSystem     = rows[i]["IsSysModule"].ToString(),
                        ImageAddress = rows[i]["ImagesAddress"].ToString(),
                    };
                    list.Add(firstMenu);
                    DataRow[] r_list = dt.Select(string.Format("ParentID={0}", rows[i]["PKID"]));
                    if (r_list.Length > 0)
                    {
                        firstMenu.Children = new List <MenuClass>();
                        for (int j = 0; j < r_list.Length; j++)
                        {
                            MenuClass secondMenu = new MenuClass
                            {
                                MenuId       = Convert.ToInt32(r_list[j]["PKID"].ToString()),
                                MenuName     = r_list[j]["Name"].ToString(),
                                ParentID     = Convert.ToInt32(r_list[j]["ParentID"].ToString()),
                                IsSystem     = r_list[j]["IsSysModule"].ToString(),
                                ImageAddress = r_list[j]["ImagesAddress"].ToString(),
                            };
                            firstMenu.Children.Add(secondMenu);
                            DataRow[] rows2 = dt.Select(string.Format("ParentID={0}", r_list[j]["PKID"]));
                            if (rows2.Length > 0)
                            {
                                secondMenu.Children = new List <MenuClass>();
                                for (int k = 0; k < rows2.Length; k++)
                                {
                                    MenuClass threeMenu = new MenuClass
                                    {
                                        MenuId       = Convert.ToInt32(rows2[k]["PKID"].ToString()),
                                        MenuName     = rows2[k]["Name"].ToString(),
                                        ParentID     = Convert.ToInt32(rows2[k]["ParentID"].ToString()),
                                        IsSystem     = rows2[k]["IsSysModule"].ToString(),
                                        ImageAddress = rows2[k]["ImagesAddress"].ToString(),
                                        MenuUrl      = rows2[k]["PageAddress"].ToString(),
                                    };
                                    secondMenu.Children.Add(threeMenu);
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
        public int AddNewModule(Module module)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ModuleCode", module.ModuleCode),
                new SqlParameter("@LecturerID", module.LecturerID),
                new SqlParameter("@Date", module.Date)
            };

            return DBHelper.ExecuteNonQueryGetLastID("sp_AddNewModule", CommandType.StoredProcedure, parameters);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            moduleID = Convert.ToInt32(Request.QueryString["id"]);

            //get module name
            ModuleHandler moduleHandler = new ModuleHandler();
            Module module = new Module();
            module = moduleHandler.GetModuleDetails(Convert.ToInt32(moduleID));

            litHeader.Text = "<div class='alert alert-info'>" + module.ModuleCode + "</div>";
        }
        protected void btnAddModule_Click(object sender, EventArgs e)
        {
            int lastID = 0;

            Module newModule = new Module();
            newModule.ModuleCode = txtModuleCode.Value;
            newModule.LecturerID = Convert.ToInt32(Session["lecturerID"]);
            newModule.Date = DateTime.Now;

            ModuleHandler moduleHandler = new ModuleHandler();

            lastID = moduleHandler.AddNewModule(newModule);
            if (lastID > 0)
            {
                litHeader.Text = "Module added";

                Response.Redirect("AddStudents.aspx?module=" + lastID);
            }
            else
            {
                litHeader.Text = "Failed to add module";
            }
        }
 public int AddNewModule(Module module)
 {
     return moduleDB.AddNewModule(module);
 }
        public Module GetModuleDetails(int moduleID)
        {
            //gets list of disabled modules linked to a lecturer

            Module module = null;

            SqlParameter[] paramaters = new SqlParameter[]
            {
                new SqlParameter("@ModuleID", moduleID),
            };

            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetModuleDetails", CommandType.StoredProcedure, paramaters))
            {
                if (table.Rows.Count == 1)
                {
                    DataRow row = table.Rows[0];

                    module = new Module();

                    module.ModuleID = Convert.ToInt32(row["ModuleID"]);
                    module.ModuleCode = row["ModuleCode"].ToString();
                    module.LecturerID = Convert.ToInt32(row["LecturerID"]);
                    module.Date = Convert.ToDateTime(row["Date"]);
                }
            }

            return module;
        }