protected void resetButton_Click(object sender, EventArgs e) { try { CourseManager aCourseManager = new CourseManager(); string msg = aCourseManager.ResetCourseScheduleAndUnassignedAllCourse(); msgLabel.ForeColor = Color.Green; msgLabel.Text = msg; } catch (SqlException sqlException) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Database error.See details error: " + sqlException.Message; } catch (Exception exception) { msgLabel.ForeColor = Color.Red; string errorMessage = "Unknow error occured."; errorMessage += exception.Message; if (exception.InnerException != null) { errorMessage += exception.InnerException.Message; } msgLabel.Text = errorMessage; } }
protected void saveButton_Click(object sender, EventArgs e) { if (!IsValid) { return; } try { Course aCourse = new Course(); aCourse.CourseCode = codeTextBox.Value; aCourse.CourseName = titleTextBox.Value; aCourse.Credit = Convert.ToDouble(creditTextBox.Value); aCourse.Description = descriptionTextBox.Value; aCourse.CourseStatus = 0; aDepartmentManager = new DepartmentManager(); aCourse.ADepartment = aDepartmentManager.GetDepartment(Convert.ToInt16(departmentDropDownList.Text)); SemesterManager aSemesterManager = new SemesterManager(); aCourse.ASemester = aSemesterManager.GetSemester(Convert.ToInt16(semesterDropDownList.Text)); CourseManager aCourseManager = new CourseManager(); string msg = aCourseManager.SaveCourse(aCourse); if (msg == "Saved") { msgLabel.ForeColor = Color.Green; msgLabel.Text = msg; ClearAllTextBoxes(); } else { msgLabel.ForeColor = Color.Red; msgLabel.Text = msg; } } catch (SqlException sqlException) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Database error.See details error: " + sqlException.Message; } catch (Exception exception) { msgLabel.ForeColor = Color.Red; string errorMessage = "Unknow error occured."; errorMessage += exception.Message; if (exception.InnerException != null) { errorMessage += exception.InnerException.Message; } msgLabel.Text = errorMessage; } }
protected void Page_Load(object sender, EventArgs e) { msgLabel.Text = ""; try { List<Course> courses = new List<Course>(); List<Department> departments = new List<Department>(); departmentDropDownList.DataTextField = "DepartmentCode"; departmentDropDownList.DataValueField = "departmentId"; courseDropDownList.DataTextField = "courseCode"; courseDropDownList.DataValueField = "courseId"; if (!IsPostBack) { aDepartmentManager = new DepartmentManager(); departments = aDepartmentManager.GetAllDepartments(); aCourseManager = new CourseManager(); courses = aCourseManager.GetAllCourses(); departmentDropDownList.DataSource = departments; departmentDropDownList.DataBind(); courseDropDownList.DataSource = courses; courseDropDownList.DataBind(); } } catch (SqlException sqlException) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Database error.See details error: " + sqlException.Message; } catch (Exception exception) { msgLabel.ForeColor = Color.Red; string errorMessage = "Unknow error occured."; errorMessage += exception.Message; if (exception.InnerException != null) { errorMessage += exception.InnerException.Message; } msgLabel.Text = errorMessage; } }
private bool DoesThisCourseExist(TeacherCourse aTeacherCourse) { int status = 0; List <Course> courses = new List <Course>(); CourseManager aCourseManager = new CourseManager(); courses = aCourseManager.GetAllCourses(); foreach (Course course in courses) { if (aTeacherCourse.CourseId == course.CourseId && course.CourseStatus == 1) { status = 1; } } if (status == 1) { return(true); } else { return(false); } }
protected void pdfButton_Click(object sender, EventArgs e) { try { List<Course> courses = new List<Course>(); Course course = new Course(); CourseManager aCourseManager = new CourseManager(); course.ADepartment = new Department(); course.ASemester = new Semester(); course.ADepartment.DepartmentId = Convert.ToInt16(departmentDropDownList.Text); course.ASemester.SemesterId = Convert.ToInt16(semesterDropDownList.Text); course.CourseStatus = 0; courses = aCourseManager.GetAllUnassignedCourses(course); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35); string pdfFilePath = Server.MapPath("CoursePdf.pdf"); PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(pdfFilePath, FileMode.Create)); doc.Open(); //Open Document to write iTextSharp.text.Font font8 = FontFactory.GetFont("ARIAL", 7); string heading = " Unassigned Course Details for Department: " + departmentDropDownList.SelectedItem + " and Semester: " + semesterDropDownList.SelectedItem; Paragraph reportHeading = new Paragraph(heading); if (courses != null) { PdfPTable PdfTable = new PdfPTable(4); PdfPCell PdfPCell = null; PdfPCell = new PdfPCell(new Phrase(new Chunk("Course Code", font8))); PdfTable.AddCell(PdfPCell); PdfPCell = new PdfPCell(new Phrase(new Chunk("Course Name", font8))); PdfTable.AddCell(PdfPCell); PdfPCell = new PdfPCell(new Phrase(new Chunk("Credit", font8))); PdfTable.AddCell(PdfPCell); PdfPCell = new PdfPCell(new Phrase(new Chunk("Course Description", font8))); PdfTable.AddCell(PdfPCell); foreach (Course aCourse in courses) { PdfPCell = new PdfPCell(new Phrase(new Chunk(aCourse.CourseCode, font8))); PdfTable.AddCell(PdfPCell); PdfPCell = new PdfPCell(new Phrase(new Chunk(aCourse.CourseName, font8))); PdfTable.AddCell(PdfPCell); PdfPCell = new PdfPCell(new Phrase(new Chunk(aCourse.Description, font8))); PdfTable.AddCell(PdfPCell); PdfPCell = new PdfPCell(new Phrase(new Chunk((aCourse.Credit).ToString(), font8))); PdfTable.AddCell(PdfPCell); } PdfTable.SpacingBefore = 15f; doc.Add(reportHeading); doc.Add(PdfTable); doc.Close(); WebClient client = new WebClient(); Byte[] buffer = client.DownloadData(pdfFilePath); Response.ContentType = "application/pdf"; Response.AddHeader("content-length", buffer.Length.ToString()); Response.BinaryWrite(buffer); } } catch (SqlException sqlException) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Database error.See details error: " + sqlException.Message; } catch (Exception exception) { msgLabel.ForeColor = Color.Red; string errorMessage = "Unknow error occured."; errorMessage += exception.Message; if (exception.InnerException != null) { errorMessage += exception.InnerException.Message; } msgLabel.Text = errorMessage; } }
private void GetAllUnassignedCourses() { try { List<Course> courses = new List<Course>(); Course aCourse = new Course(); CourseManager aCourseManager = new CourseManager(); aCourse.ADepartment = new Department(); aCourse.ASemester = new Semester(); aCourse.ADepartment.DepartmentId = Convert.ToInt16(departmentDropDownList.Text); aCourse.ASemester.SemesterId = Convert.ToInt16(semesterDropDownList.Text); aCourse.CourseStatus = 0; courses = aCourseManager.GetAllUnassignedCourses(aCourse); courseGridView.DataSource = courses; courseGridView.DataBind(); } catch (Exception exception) { throw exception; } }
private bool DoesThisCourseExist(TeacherCourse aTeacherCourse) { int status = 0; List<Course> courses = new List<Course>(); CourseManager aCourseManager = new CourseManager(); courses = aCourseManager.GetAllCourses(); foreach (Course course in courses) { if (aTeacherCourse.CourseId == course.CourseId && course.CourseStatus == 1) { status = 1; } } if (status == 1) return true; else { return false; } }
protected void Page_Load(object sender, EventArgs e) { msgLabel.Text = ""; try { departmentDropDownList.DataTextField = "DepartmentCode"; departmentDropDownList.DataValueField = "departmentId"; semesterDropDownList.DataTextField = "SemesterName"; semesterDropDownList.DataValueField = "SemesterId"; dayDropDownList.DataTextField = "dayName"; dayDropDownList.DataValueField = "dayId"; buildingDropDownList.DataTextField = "buildingName"; buildingDropDownList.DataValueField = "buildingId"; courseDropDownList.DataTextField = "courseCode"; courseDropDownList.DataValueField = "courseId"; roomDropDownList.DataTextField = "roomName"; roomDropDownList.DataValueField = "roomId"; if (!IsPostBack) { List<Course> courses = new List<Course>(); List<Day> days = new List<Day>(); List<Department> departments = new List<Department>(); List<Semester> semester = new List<Semester>(); List<Building> buildings = new List<Building>(); aDepartmentManager = new DepartmentManager(); departments = aDepartmentManager.GetAllDepartments(); SemesterManager aSemesterManager = new SemesterManager(); semester = aSemesterManager.GetAllSemesters(); aScheduleManager = new ScheduleManager(); buildings = aScheduleManager.GetAllBuildings(); days = aScheduleManager.GetAllDays(); aCourseManager = new CourseManager(); courses = aCourseManager.GetAllCourses(); dayDropDownList.DataSource = days; dayDropDownList.DataBind(); departmentDropDownList.DataSource = departments; departmentDropDownList.DataBind(); semesterDropDownList.DataSource = semester; semesterDropDownList.DataBind(); buildingDropDownList.DataSource = buildings; buildingDropDownList.DataBind(); courseDropDownList.DataSource = courses; courseDropDownList.DataBind(); } } catch (Exception exception) { msgLabel.ForeColor = Color.Red; msgLabel.Text = exception.Message; } }
protected void semesterDropDownList_SelectedIndexChanged(object sender, EventArgs e) { try { CourseManager aCourseManager = new CourseManager(); int departmentId = Convert.ToInt16(departmentDropDownList.Text); int semesteId = Convert.ToInt16(semesterDropDownList.Text); List<Course> courses = new List<Course>(); courses = aCourseManager.GetAllCoursesByDepartment(departmentId, semesteId); courseDropDownList.DataSource = courses; courseDropDownList.DataBind(); } catch (SqlException sqlException) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Database error.See details error: " + sqlException.Message; } catch (Exception exception) { msgLabel.ForeColor = Color.Red; string errorMessage = "Unknow error occured."; errorMessage += exception.Message; if (exception.InnerException != null) { errorMessage += exception.InnerException.Message; } msgLabel.Text = errorMessage; } }
private void ShowCourses() { try { List<ShowCourse> showCourses = new List<ShowCourse>(); CourseManager aCourseManager = new CourseManager(); int departmentId = Convert.ToInt16(departmentDropDownList.Text); showCourses = aCourseManager.GetScheduleCoursesByDepartmentId(departmentId); courseGridView.DataSource = showCourses; courseGridView.DataBind(); } catch (Exception exception) { throw exception; } }
private void GetCourses() { try { Course aCourse = new Course(); CourseManager aCourseManager = new CourseManager(); aCourse = aCourseManager.GetCourse(Convert.ToInt16(courseTitleDropDownList.Text)); nameTextBox.Value = aCourse.CourseName; creditTextBox.Value = aCourse.Credit.ToString(); } catch (Exception exception) { throw exception; } }