//Loads other events (positive exceptions and tests) for a class event private void LoadOtherEvents() { BusinessLayer.Course objCourse = new Course(); objCourse.CourseId = _courseid; /* * A Class MUST have an event of it's own to have EXTRA CLASSES. * A Class can HOWEVER have TEST EVENTS without an event of it's own */ objCourse.EventID = eventid[3]; objCourse.LoadData(); //Load Events depending upon whether class re-occurs or not DataTable dtbl = objCourse.LoadOtherEvents(IsRecurringSeries); grdEvents.DataSource = dtbl; if (dtbl.Rows.Count==0) { btnEdit.Enabled = false; btnDel.Enabled = false; } else { btnEdit.Enabled = true; btnDel.Enabled = true; } if (!IsRecurringSeries && HasTestInitialEvent && HasTestMidtermEvent && HasTestFinalEvent) btnAdd.Enabled = false; else btnAdd.Enabled = true; if (Common.LogonType == 2) { this.btnDelete.Enabled = false; this.btnSave.Enabled = false; this.btnAdd.Enabled = false; this.btnDel.Enabled = false; this.btn_ClearRecc.Enabled = false; this.btnEdit.Text = "View"; } }
public void LoadData() { if (_mode == "Edit" || _mode == "AddClone") { if (_mode == "Edit") this.Text = "Editing Course..."; else { this.Text = "Adding Course Clone..."; btnDelete.Enabled = false; } Scheduler.BusinessLayer.Course objCourse=new Scheduler.BusinessLayer.Course(); objCourse.CourseId = _courseid; objCourse.LoadData(); IsRecurringSeries = objCourse.IsRecurring(); bool[] boolArray = objCourse.CheckTestEvents(); HasTestInitialEvent = boolArray[0]; HasTestMidtermEvent = boolArray[1]; HasTestFinalEvent = boolArray[2]; foreach(DataRow dr in objCourse.CourseDataTable.Rows) { //Get the Client/Department/Program if(dr["Client"]!=System.DBNull.Value) cmbClient.Text = dr["Client"].ToString(); intClientID = Common.GetCompanyID( "Select ContactID From Contact " + "Where (CompanyName=@CompanyName OR NickName=@CompanyName) ", cmbClient.Text ); if(intClientID!=0) { llblClient.Tag = intClientID; Common.PopulateDropdown( cmbDept, "Select CASE " + "WHEN C.NickName IS NULL THEN C.CompanyName " + "WHEN C.NickName = '' THEN C.CompanyName " + "ELSE C.NickName " + "END AS CompanyName From " + "Department D, Contact C Where D.ContactID=C.ContactID " + "and D.ClientID=" + intClientID + " Order By CompanyName"); } if(dr["Department"]!=System.DBNull.Value) cmbDept.Text = dr["Department"].ToString(); string query = "Select CASE " + "WHEN C.NickName IS NULL THEN C.CompanyName " + "WHEN C.NickName = '' THEN C.CompanyName " + "ELSE C.NickName " + "END AS CompanyName From " + "Department D, Contact C Where D.ContactID=C.ContactID and " + "D.DepartmentStatus=1 and D.ClientID=" + intClientID + " Order By CompanyName"; IDataReader reader = DAC.SelectStatement(query); while (reader.Read()) { if (reader["CompanyName"] != DBNull.Value && reader["CompanyName"].ToString() != cmbDept.Text) { cmbDept.Items.Remove(reader["CompanyName"].ToString()); ; } } intDepartmentID = Common.GetCompanyID( "Select D.DepartmentID, C.ContactID From Department D, Contact C " + "Where D.ContactID=C.ContactID and (C.CompanyName=@CompanyName OR C.NickName=@CompanyName) and D.ClientID = '" + intClientID + "' ", cmbDept.Text ); if (intDepartmentID != 0) { llbDepartment.Tag = intDepartmentID; Common.PopulateDropdown( cmbProgram, "Select CASE " + "WHEN NickName IS NULL THEN [Name] " + "WHEN NickName = '' THEN [Name] " + "ELSE NickName " + "END AS [Name] From " + "Program Where DepartmentID=" + intDepartmentID + " Order By [Name]"); } if (dr["Program"] != System.DBNull.Value) { llblProgram.Tag = dr["ProgramId"].ToString(); cmbProgram.SelectedIndex = cmbProgram.Items.IndexOf(dr["Program"].ToString()); } query = "Select CASE " + "WHEN NickName IS NULL THEN [Name] " + "WHEN NickName = '' THEN [Name] " + "ELSE NickName " + "END AS [Name] From " + "Program Where ProgramStatus=1 and DepartmentID=" + intDepartmentID + " Order By [Name]"; reader = DAC.SelectStatement(query); while (reader.Read()) { if (reader["Name"] != DBNull.Value && reader["Name"].ToString() != cmbProgram.Text) { cmbProgram.Items.Remove(reader["Name"].ToString()); ; } } txtCourseName.Text = dr["Name"].ToString(); if (_mode == "AddClone") txtCourseName.Text = "Copy of " + txtCourseName.Text; txtNamePhonetic.Text = dr["NamePhonetic"].ToString(); txtNameRomaji.Text = dr["NameRomaji"].ToString(); txtNickName.Text = dr["NickName"].ToString(); txtDescription.Text = dr["Description"].ToString(); txtRemarks.Text = dr["SpecialRemarks"].ToString(); txtCurriculam.Text = dr["Curriculam"].ToString(); cmbCourseType.Text = dr["CourseType"].ToString(); txtNumberStudents.Text = dr["NumberStudents"].ToString(); txtHomeWorkMinutes.Text = dr["HomeWorkMinutes"].ToString(); textBoxBreakDuration.Text = dr["BreakDuration"].ToString(); if (dr["CourseStatus"].ToString() == "Active") cmbStatus.SelectedIndex = 0; else { cmbStatus.SelectedIndex = 1; //chkEventModified.Checked = true; } if (_mode == "Edit") { txtInitialEvent.Text = dr["TestInitialEventId"].ToString(); txtMidtermEvent.Text = dr["TestMidTermEventId"].ToString(); txtFinalEvent.Text = dr["TestFinalEventId"].ToString(); txtEvent.Text = dr["EventID"].ToString(); eventid[0] = Convert.ToInt32(dr["TestInitialEventId"].ToString()); eventid[1] = Convert.ToInt32(dr["TestMidTermEventId"].ToString()); eventid[2] = Convert.ToInt32(dr["TestFinalEventId"].ToString()); eventid[3] = Convert.ToInt32(dr["EventID"].ToString()); //Making sure all events on record exist if (eventid[0] > 0) { if (!objCourse.IsEventExists(eventid[0])) eventid[0] = 0; } if (eventid[1] > 0) { if (!objCourse.IsEventExists(eventid[1])) eventid[1] = 0; } if (eventid[2] > 0) { if (!objCourse.IsEventExists(eventid[2])) eventid[2] = 0; } if (eventid[3] > 0) { if (!objCourse.IsEventExists(eventid[3])) eventid[3] = 0; } txtInitialForm.Text = dr["TestInitialForm"].ToString(); txtMidtermForm.Text = dr["TestMidTermForm"].ToString(); txtFinalForm.Text = dr["TestFinalForm"].ToString(); } else { txtInitialEvent.Text = String.Empty; txtMidtermEvent.Text = String.Empty; txtFinalEvent.Text = String.Empty; txtEvent.Text = String.Empty; eventid[0] = 0; eventid[1] = 0; eventid[2] = 0; eventid[3] = 0; txtInitialForm.Text = String.Empty; txtMidtermForm.Text = String.Empty; txtFinalForm.Text = String.Empty; } break; } if (_mode == "Edit") { //Load Events if any string strHint = ""; llblInitialEvt.Text = objCourse.getEventText(txtInitialEvent.Text, "Initial", ref strHint); if (strHint == "None") txtInitialEvent.Text = "0"; strHint = ""; llblMidEvt.Text = objCourse.getEventText(txtMidtermEvent.Text, "Midterm", ref strHint); if (strHint == "None") txtMidtermEvent.Text = "0"; strHint = ""; llblFinalEvt.Text = objCourse.getEventText(txtFinalEvent.Text, "Final", ref strHint); if (strHint == "None") txtFinalEvent.Text = "0"; strHint = ""; llblEvent.Text = objCourse.getEventText(txtEvent.Text, "Event", ref strHint); if (strHint != "") llblEvent.Text = strHint; if (strHint == "None") txtEvent.Text = "0"; strHint = ""; if (eventid[intIndex] > 0) LoadEvent(eventid[intIndex], calendareventid[intIndex]); } else { llblInitialEvt.Text = String.Empty; txtInitialEvent.Text = "0"; llblMidEvt.Text = String.Empty; txtMidtermEvent.Text = "0"; llblFinalEvt.Text = String.Empty; txtFinalEvent.Text = "0"; llblEvent.Text = String.Empty; txtEvent.Text = "0"; } if (_mode == "Edit") { string query = "Select CASE " + "WHEN NickName IS NULL THEN CompanyName " + "WHEN NickName = '' THEN CompanyName " + "ELSE NickName " + "END AS CompanyName From " + "Contact Where ContactType=2 and " + "ContactStatus=1 Order By CompanyName"; IDataReader reader = DAC.SelectStatement(query); while (reader.Read()) { if (reader["CompanyName"] != DBNull.Value && reader["CompanyName"].ToString() != cmbClient.Text) cmbClient.Items.Remove(reader["CompanyName"].ToString()); } query = "Select " + "CASE " + "WHEN NickName IS NULL THEN LastName + ', ' + FirstName " + "WHEN NickName = '' THEN LastName + ', ' + FirstName " + "ELSE NickName " + "END as TeacherName From " + "Contact Where ContactType=1 and " + "ContactStatus=1 Order By LastName, FirstName "; reader = DAC.SelectStatement(query); while (reader.Read()) { if (reader["TeacherName"] != DBNull.Value && reader["TeacherName"].ToString() != cmbTeacher2_I.Text && reader["TeacherName"].ToString() != cmbTeacher1_I.Text) { cmbTeacher1_I.Items.Remove(reader["TeacherName"].ToString()); cmbTeacher2_I.Items.Remove(reader["TeacherName"].ToString()); } } } } else { this.Text = "Adding Class..."; string query = "Select CASE " + "WHEN NickName IS NULL THEN CompanyName " + "WHEN NickName = '' THEN CompanyName " + "ELSE NickName " + "END as CompanyName From " + "Contact Where ContactType=2 and " + "ContactStatus=1 Order By CompanyName"; IDataReader reader = DAC.SelectStatement(query); while (reader.Read()) { if (reader["CompanyName"] != DBNull.Value ) cmbClient.Items.Remove(reader["CompanyName"].ToString()); } query = "Select " + "CASE " + "WHEN NickName IS NULL THEN LastName + ', ' + FirstName " + "WHEN NickName = '' THEN LastName + ', ' + FirstName " + "ELSE NickName " + "END as TeacherName From " + "Contact Where ContactType=1 and " + "ContactStatus=1 Order By LastName, FirstName "; reader = DAC.SelectStatement(query); while (reader.Read()) { if (reader["TeacherName"] != DBNull.Value) { cmbTeacher1_I.Items.Remove(reader["TeacherName"].ToString()); cmbTeacher2_I.Items.Remove(reader["TeacherName"].ToString()); } } cmbClient.Text = String.Empty; cmbDept.Text = String.Empty; cmbProgram.Text = String.Empty; txtCourseName.Text = String.Empty; txtNamePhonetic.Text = String.Empty; txtNameRomaji.Text = String.Empty; txtNickName.Text = String.Empty; txtDescription.Text = String.Empty; txtRemarks.Text = String.Empty; txtCurriculam.Text = String.Empty; cmbCourseType.Text = String.Empty; txtNumberStudents.Text = String.Empty; txtHomeWorkMinutes.Text = String.Empty; textBoxBreakDuration.Text = String.Empty; txtInitialEvent.Text = String.Empty; txtMidtermEvent.Text = String.Empty; txtFinalEvent.Text = String.Empty; txtEvent.Text = String.Empty; eventid[0] = 0; eventid[1] = 0; eventid[2] = 0; eventid[3] = 0; txtInitialForm.Text = String.Empty; txtMidtermForm.Text = String.Empty; txtFinalForm.Text = String.Empty; cmbStatus.SelectedIndex = 0; SetEventModificationControls(false); //load Events if any llblInitialEvt.Text = String.Empty; txtInitialEvent.Text = "0"; llblMidEvt.Text = String.Empty; txtMidtermEvent.Text = "0"; llblFinalEvt.Text = String.Empty; txtFinalEvent.Text = "0"; llblEvent.Text = String.Empty; llblEvent.Text = String.Empty; } }