コード例 #1
0
        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>";
                }

            }
        }
コード例 #2
0
        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";
            }
        }