public SemesterView(CommonExchange.SemesterInformation semInfo) { this.InitializeComponent(); _semInfo = semInfo; this.Load += new EventHandler(ClassLoad); this.btnDone.Click += new EventHandler(btnDoneClick); }
} //----------------------- #endregion #region Programmer-Defined Void Procedures //this function returns the last opened semeter information public CommonExchange.SemesterInformation GetNextOpenedSemesterInformation(CommonExchange.SysAccess userInfo, CommonExchange.SchoolYear yearInfo, CommonExchange.SchoolSemester semesterId) { CommonExchange.SemesterInformation nextSemInfo = new CommonExchange.SemesterInformation(); nextSemInfo.SchoolYearInfo.YearId = yearInfo.YearId; nextSemInfo.SemesterId = (Byte)semesterId; nextSemInfo.DateStart = this.GetSemesterInformationDateStart(userInfo).ToString(); nextSemInfo.DateEnd = this.GetSemesterInformationDateEnd(DateTime.Parse(nextSemInfo.DateStart), nextSemInfo.SemesterId).ToString(); nextSemInfo.SchoolYearDescription = this.GetSchoolYearInformationDescription(nextSemInfo.SchoolYearInfo.YearId); nextSemInfo.SchoolSemesterDescription = this.GetSchoolSemesterDescription(nextSemInfo.SemesterId); return(nextSemInfo); } //---------------------------------
//this procedure insterst a school semester information public void InsertSemesterInformation(CommonExchange.SysAccess userInfo, CommonExchange.SemesterInformation semInfo) { using (RemoteClient.RemCntSchoolYearSemesterManager remClient = new RemoteClient.RemCntSchoolYearSemesterManager()) { remClient.InsertSemesterInformation(userInfo, ref semInfo); } if (_semesterTable != null) { DataRow newRow = _semesterTable.NewRow(); newRow["sysid_semester"] = semInfo.SemesterSysId; newRow["year_id"] = semInfo.SchoolYearInfo.YearId; newRow["semester_id"] = semInfo.SemesterId; newRow["date_start"] = semInfo.DateStart; newRow["date_end"] = semInfo.DateEnd; newRow["year_description"] = semInfo.SchoolYearDescription; newRow["semester_description"] = semInfo.SchoolSemesterDescription; _semesterTable.Rows.Add(newRow); _semesterTable.AcceptChanges(); } } //---------------------------------
} //---------------------------- //this function gets the semester information details public CommonExchange.SemesterInformation GetDetailsSemesterInformation(String semId) { CommonExchange.SemesterInformation semInfo = new CommonExchange.SemesterInformation(); if (_semesterTable != null) { String strFilter = "sysid_semester = '" + semId + "'"; DataRow[] selectRow = _semesterTable.Select(strFilter, "sysid_semester DESC"); foreach (DataRow semRow in selectRow) { semInfo.SemesterSysId = RemoteServerLib.ProcStatic.DataRowConvert(semRow, "sysid_semester", ""); semInfo.SchoolYearInfo.YearId = RemoteServerLib.ProcStatic.DataRowConvert(semRow, "year_id", ""); semInfo.SemesterId = RemoteServerLib.ProcStatic.DataRowConvert(semRow, "semester_id", Byte.Parse("0")); semInfo.DateStart = RemoteServerLib.ProcStatic.DataRowConvert(semRow, "date_start", ""); semInfo.DateEnd = RemoteServerLib.ProcStatic.DataRowConvert(semRow, "date_end", ""); semInfo.SchoolYearDescription = RemoteServerLib.ProcStatic.DataRowConvert(semRow, "year_description", ""); semInfo.SchoolSemesterDescription = RemoteServerLib.ProcStatic.DataRowConvert(semRow, "semester_description", ""); } } return(semInfo); } //-----------------------------------
} //------------------------------ //############################################END BUTTON btnCancel EVENTS###################################################### //################################################BUTTON btnOpen EVENTS######################################################## //event is raised when the button is clicked private void btnOpenClick(object sender, EventArgs e) { try { String strMsg = "Are you sure you want to officially open a new school year?"; DialogResult msgResult = MessageBox.Show(strMsg, "Confirm Open", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (msgResult == DialogResult.Yes) { strMsg = "The following has been officially opened:\n\nSchool Year: " + _yearInfo.Description + "\nSchool Year (SUMMER): " + _yearInfo.Description + "\n\nSemester: First Semester\nSemester: Second Semester\nSemester: Summer"; this.Cursor = Cursors.WaitCursor; //inserts the regular school year _yearSemManager.InsertSchoolYear(_userInfo, ref _yearInfo); //------------------------------------ //inserts the first semester CommonExchange.SemesterInformation firstSemInfo = _yearSemManager.GetNextOpenedSemesterInformation(_userInfo, _yearInfo, CommonExchange.SchoolSemester.FirstSemester); _yearSemManager.InsertSemesterInformation(_userInfo, firstSemInfo); //-------------------------------------- //inserts the second semester CommonExchange.SemesterInformation secondSemInfo = _yearSemManager.GetNextOpenedSemesterInformation(_userInfo, _yearInfo, CommonExchange.SchoolSemester.SecondSemester); _yearSemManager.InsertSemesterInformation(_userInfo, secondSemInfo); //inserts the school year SUMMER CommonExchange.SchoolYear summerYearInfo = _yearSemManager.GetNextOpenedSchoolYearInformation(_userInfo, _yearInfo); _yearSemManager.InsertSchoolYearSummer(_userInfo, _yearInfo, ref summerYearInfo); //----------------------------------- //inserts the summer semester CommonExchange.SemesterInformation summerSemInfo = _yearSemManager.GetNextOpenedSemesterInformation(_userInfo, summerYearInfo, CommonExchange.SchoolSemester.Summer); _yearSemManager.InsertSemesterInformation(_userInfo, summerSemInfo); //---------------------------------------- this.Cursor = Cursors.Arrow; MessageBox.Show(strMsg, "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); _hasCreated = true; this.Close(); } else if (msgResult == DialogResult.Cancel) { this.Close(); } } catch (Exception ex) { RemoteClient.ProcStatic.ShowErrorDialog(ex.Message, "Error in Opening A School Year"); } finally { this.Cursor = Cursors.Arrow; } } //------------------------------------