} //-------------------------- //this function returns a subject information details public CommonExchange.SubjectInformation GetDetailsSubjectInformation(String subjectSysId) { CommonExchange.SubjectInformation subjectInfo = new CommonExchange.SubjectInformation(); if (_subjectTable != null) { String strFilter = "sysid_subject = '" + subjectSysId + "'"; DataRow[] selectRow = _subjectTable.Select(strFilter, "subject_code ASC"); foreach (DataRow subjectRow in selectRow) { subjectInfo.SubjectSysId = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "sysid_subject", ""); subjectInfo.CourseGroupInfo.CourseGroupId = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "course_group_id", ""); subjectInfo.DepartmentInfo.DepartmentId = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "department_id", ""); subjectInfo.SubjectCode = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "subject_code", ""); subjectInfo.DescriptiveTitle = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "descriptive_title", ""); subjectInfo.LectureUnits = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "lecture_units", Byte.Parse("0")); subjectInfo.LabUnits = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "lab_units", Byte.Parse("0")); subjectInfo.NoHours = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "no_hours", ""); subjectInfo.OtherInformation = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "other_information", ""); subjectInfo.CourseGroupInfo.IsSemestral = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "is_semestral", false); subjectInfo.CourseGroupInfo.GroupNo = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "group_no", Byte.Parse("0")); subjectInfo.DepartmentInfo.DepartmentName = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "department_name", ""); subjectInfo.IsNonAcademic = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "is_non_academic", false); subjectInfo.CategoryInfo.CategoryId = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "category_id", String.Empty); subjectInfo.IsOpenAccess = RemoteServerLib.ProcStatic.DataRowConvert(subjectRow, "is_open_access", false); } } return(subjectInfo); } //--------------------------------------
//this procedure inserts a new subject information public void InsertSubjectInformation(CommonExchange.SysAccess userInfo, CommonExchange.SubjectInformation subjectInfo) { using (RemoteClient.RemCntCourseManager remClient = new RemoteClient.RemCntCourseManager()) { remClient.InsertSubjectInformation(userInfo, ref subjectInfo, _requisiteTable); } if (_subjectTable != null) { DataRow newRow = _subjectTable.NewRow(); newRow["sysid_subject"] = subjectInfo.SubjectSysId; newRow["course_group_id"] = subjectInfo.CourseGroupInfo.CourseGroupId; newRow["department_id"] = subjectInfo.DepartmentInfo.DepartmentId; newRow["subject_code"] = subjectInfo.SubjectCode; newRow["descriptive_title"] = subjectInfo.DescriptiveTitle; newRow["lecture_units"] = subjectInfo.LectureUnits; newRow["lab_units"] = subjectInfo.LabUnits; newRow["no_hours"] = subjectInfo.NoHours; newRow["other_information"] = subjectInfo.OtherInformation; newRow["is_semestral"] = subjectInfo.CourseGroupInfo.IsSemestral; newRow["group_no"] = this.GetCourseGroupNo(subjectInfo.CourseGroupInfo.CourseGroupId); newRow["department_name"] = subjectInfo.DepartmentInfo.DepartmentName; newRow["is_non_academic"] = subjectInfo.IsNonAcademic; _subjectTable.Rows.Add(newRow); _subjectTable.AcceptChanges(); _requisiteTable.AcceptChanges(); } } //-------------------------------------
} //----------------------------------------- //############################################END COMBOBOX cboYearSemester EVENTS############################################## //##############################################BUTTON btnSearchSubject EVENTS#################################################### //event is raised when the button is clicked private void btnSearchSubjectClick(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; using (SubjectSearchOnTextboxList frmSearch = new SubjectSearchOnTextboxList(_userInfo, _specialManager)) { frmSearch.AdoptGridSize = true; frmSearch.ShowDialog(this); if (frmSearch.HasSelected) { _subjectInfo = _specialManager.GetDetailsSubjectInformation(frmSearch.PrimaryId); _specialInfo.SubjectSysId = _subjectInfo.SubjectSysId; _specialInfo.IsSemestral = _subjectInfo.CourseGroupInfo.IsSemestral; _specialInfo.SubjectDepartmentName = _subjectInfo.DepartmentInfo.DepartmentName; lblSysIdSubject.Text = _subjectInfo.SubjectSysId; lblSubjectCodeDescription.Text = _subjectInfo.SubjectCode + " - " + _subjectInfo.DescriptiveTitle; lblSubjectDepartment.Text = _subjectInfo.DepartmentInfo.DepartmentName; lblUnitsLabHours.Text = _specialManager.GetSubjectUnitsHours(_subjectInfo.LectureUnits, _subjectInfo.LabUnits, _subjectInfo.NoHours); _specialManager.InitializeSchoolYearSemesterCombo(cboYearSemester, _subjectInfo.CourseGroupInfo.IsSemestral); if (_subjectInfo.CourseGroupInfo.IsSemestral) { _dateStart = _specialManager.GetSemesterDateStart(_specialManager.GetYearSemesterId(_subjectInfo.CourseGroupInfo.IsSemestral, this.cboYearSemester.SelectedIndex)).ToShortDateString() + " 12:00:00 AM"; _dateEnd = _specialManager.GetSemesterDateEnd(_specialManager.GetYearSemesterId(_subjectInfo.CourseGroupInfo.IsSemestral, this.cboYearSemester.SelectedIndex)).ToShortDateString() + " 11:59:59 PM"; } else { _dateStart = _specialManager.GetSchoolYearDateStart(_specialManager.GetYearSemesterId(_subjectInfo.CourseGroupInfo.IsSemestral, this.cboYearSemester.SelectedIndex)).ToShortDateString() + " 12:00:00 AM"; _dateEnd = _specialManager.GetSchoolYearDateEnd(_specialManager.GetYearSemesterId(_subjectInfo.CourseGroupInfo.IsSemestral, this.cboYearSemester.SelectedIndex)).ToShortDateString() + " 11:59:59 PM"; } this.cboYearSemester.Enabled = this.btnSearchEmployee.Enabled = this.lnkEnroll.Enabled = true; this.lnkWithdraw.Enabled = _canWithdraw; } _specialManager.SetSelectedDataTableToNull(); } } catch (Exception ex) { RemoteClient.ProcStatic.ShowErrorDialog(ex.Message, "Error Loading Subject Search Module"); } finally { this.Cursor = Cursors.Arrow; } } //-------------------------------------------
//#########################################CLASS Subject EVENTS########################################################### //event is raised when the class is loaded protected virtual void ClassLoad(object sender, EventArgs e) { _subjectInfo = new CommonExchange.SubjectInformation(); _subjectInfo.NoHours = hrmHours.SelectedHourMinute; _subjectInfo.LectureUnits = 0; _subjectInfo.LabUnits = 0; this.lnkRemove.Enabled = false; this.lblResult.Text = "0 Subject"; this.optUnits.Checked = true; this.lnkAdd.Enabled = false; }//--------------------------------
public SubjectUpdate(CommonExchange.SysAccess userInfo, CommonExchange.SubjectInformation subjectInfo, CourseLogic courseManager) { this.InitializeComponent(); _userInfo = userInfo; _subjectInfo = subjectInfo; _subjectInfoTemp = (CommonExchange.SubjectInformation)subjectInfo.Clone(); _courseManager = courseManager; this.FormClosing += new FormClosingEventHandler(ClassClosing); this.btnClose.Click += new EventHandler(btnCloseClick); this.btnUpdate.Click += new EventHandler(btnUpdateClick); }
}//--------------------------- //#############################################END COMBOBOX cboYearSemester EVENTS################################################# //##############################################BUTTON btnSearchSubject EVENTS#################################################### //event is raised when the button is clicked private void btnSearchSubjectClick(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; using (SubjectSearchOnTextboxList frmSearch = new SubjectSearchOnTextboxList(_userInfo, _scheduleManager, 0)) { frmSearch.AdoptGridSize = true; frmSearch.ShowDialog(this); if (frmSearch.HasSelected) { CommonExchange.SubjectInformation subjectInfo = _scheduleManager.GetDetailsSubjectInformation(frmSearch.PrimaryId); _schedInfo.SubjectInfo.SubjectSysId = subjectInfo.SubjectSysId; _schedInfo.SubjectInfo.CourseGroupInfo.IsSemestral = subjectInfo.CourseGroupInfo.IsSemestral; _schedInfo.SubjectInfo.DepartmentInfo.DepartmentName = subjectInfo.DepartmentInfo.DepartmentName; _schedInfo.SubjectInfo.SubjectCode = subjectInfo.SubjectCode; _schedInfo.SubjectInfo.DescriptiveTitle = subjectInfo.DescriptiveTitle; _schedInfo.SubjectInfo.DepartmentInfo.DepartmentId = subjectInfo.DepartmentInfo.DepartmentId; _schedInfo.SubjectInfo.LectureUnits = subjectInfo.LectureUnits; _schedInfo.SubjectInfo.LabUnits = subjectInfo.LabUnits; _schedInfo.SubjectInfo.NoHours = subjectInfo.NoHours; lblSysIdSubject.Text = subjectInfo.SubjectSysId; lblSubjectCodeDescription.Text = subjectInfo.SubjectCode + " - " + subjectInfo.DescriptiveTitle; lblSubjectDepartment.Text = subjectInfo.DepartmentInfo.DepartmentName; lblUnitsLabHours.Text = _scheduleManager.GetSubjectUnitsHours(subjectInfo.LectureUnits, subjectInfo.LabUnits, subjectInfo.NoHours); _scheduleManager.InitializeSchoolYearSemesterCombo(cboYearSemester, subjectInfo.CourseGroupInfo.IsSemestral); this.cboYearSemester.Enabled = this.tabSchedule.Enabled = this.lnkAddDetails.Enabled = true; this.btnSearchSubject.Visible = false; } } this.lnkAddDetails.Focus(); } catch (Exception ex) { RemoteClient.ProcStatic.ShowErrorDialog(ex.Message, "Error Loading Subject Search Module"); } finally { this.Cursor = Cursors.Arrow; } }//------------------------
} //--------------------------- //this function adds a new prerequisite subject public DataTable AddPrerequisiteSubject(CommonExchange.SubjectInformation subjectInfo) { DataRow newRow = _requisiteTable.NewRow(); newRow["prerequisite_id"] = --_requisiteCounter; newRow["prerequisite_subject"] = subjectInfo.SubjectSysId; newRow["subject_code"] = subjectInfo.SubjectCode; newRow["descriptive_title_no_freeze"] = subjectInfo.DescriptiveTitle; newRow["department_name"] = subjectInfo.DepartmentInfo.DepartmentName; newRow["lecture_units"] = subjectInfo.LectureUnits; newRow["lab_units"] = subjectInfo.LabUnits; newRow["no_hours"] = subjectInfo.NoHours; _requisiteTable.Rows.Add(newRow); DataTable newTable = new DataTable("SubjectPrerequisiteTempTable"); newTable.Columns.Add("prerequisite_id", System.Type.GetType("System.Int64")); newTable.Columns.Add("subject_code", System.Type.GetType("System.String")); newTable.Columns.Add("descriptive_title_no_freeze", System.Type.GetType("System.String")); newTable.Columns.Add("department_name", System.Type.GetType("System.String")); newTable.Columns.Add("lecture_units", System.Type.GetType("System.Byte")); newTable.Columns.Add("lab_units", System.Type.GetType("System.Byte")); newTable.Columns.Add("no_hours", System.Type.GetType("System.String")); DataRow[] selectRow = _requisiteTable.Select("", "subject_code ASC"); foreach (DataRow preRow in selectRow) { DataRow tempRow = newTable.NewRow(); tempRow["prerequisite_id"] = preRow["prerequisite_id"]; tempRow["subject_code"] = preRow["subject_code"]; tempRow["descriptive_title_no_freeze"] = preRow["descriptive_title_no_freeze"]; tempRow["department_name"] = preRow["department_name"]; tempRow["lecture_units"] = preRow["lecture_units"]; tempRow["lab_units"] = preRow["lab_units"]; tempRow["no_hours"] = preRow["no_hours"]; newTable.Rows.Add(tempRow); } newTable.AcceptChanges(); return(newTable); } //--------------------------------
} //------------------------------------- //this procedure updates a subject information public void UpdateSubjectInformation(CommonExchange.SysAccess userInfo, CommonExchange.SubjectInformation subjectInfo) { using (RemoteClient.RemCntCourseManager remClient = new RemoteClient.RemCntCourseManager()) { remClient.UpdateSubjectInformation(userInfo, subjectInfo, _requisiteTable); } if (_subjectTable != null) { Int32 index = 0; foreach (DataRow subjectRow in _subjectTable.Rows) { if (String.Equals(subjectInfo.SubjectSysId, subjectRow["sysid_subject"].ToString())) { DataRow editRow = _subjectTable.Rows[index]; editRow.BeginEdit(); editRow["course_group_id"] = subjectInfo.CourseGroupInfo.CourseGroupId; editRow["department_id"] = subjectInfo.DepartmentInfo.DepartmentId; editRow["subject_code"] = subjectInfo.SubjectCode; editRow["descriptive_title"] = subjectInfo.DescriptiveTitle; editRow["lecture_units"] = subjectInfo.LectureUnits; editRow["lab_units"] = subjectInfo.LabUnits; editRow["no_hours"] = subjectInfo.NoHours; editRow["other_information"] = subjectInfo.OtherInformation; editRow["is_semestral"] = subjectInfo.CourseGroupInfo.IsSemestral; editRow["group_no"] = subjectInfo.CourseGroupInfo.GroupNo; editRow["department_name"] = subjectInfo.DepartmentInfo.DepartmentName; editRow["is_non_academic"] = subjectInfo.IsNonAcademic; editRow.EndEdit(); break; } index++; } _subjectTable.AcceptChanges(); _requisiteTable.AcceptChanges(); } } //--------------------------------
} //---------------------------------- //this function determines if the subject code and descriptive title exist public Boolean IsExistCodeDescriptionSubjectInformation(CommonExchange.SysAccess userInfo, CommonExchange.SubjectInformation subjectInfo) { Boolean isExist = false; using (RemoteClient.RemCntCourseManager remClient = new RemoteClient.RemCntCourseManager()) { isExist = remClient.IsExistCodeDescriptionSubjectInformation(userInfo, subjectInfo); } return(isExist); } //--------------------------------