private void loadStudents() { XmlNode students = mDoc.LastChild; XmlNodeList studentNodes = students.ChildNodes; if (stuList == null) { stuList = new List <StudentVO>(); } else { stuList.Clear(); } foreach (XmlNode node in studentNodes) { StudentVO stu = new StudentVO(); XmlNodeList attrs = node.ChildNodes; stu.Name = attrs[0].InnerText; stu.Age = int.Parse(attrs[1].InnerText); stu.Gender = parseGender(attrs[2].InnerText); stu.StuId = attrs[3].InnerText; stu.Department = parseDepartment(attrs[4].ChildNodes[0].InnerText); stu.Major = attrs[4].ChildNodes[1].InnerText; stuList.Add(stu); } }
public async Task <StudentDisciplineVO> AddTaskAsync(StudentVO student) { StudentModel studentEntity = _studentConverter.Parse(student); if (!(GuidFormat.TryParseList(studentEntity.Disciplines, ';', out List <Guid> result))) { return(null); } //checando se não existe nenhuma disciplina repetida. foreach (Guid disc in result) { if (result.Count(x => x.Equals(disc)) > 1) { return(null); } } if (!(await _disciplineBusiness.FindAllByDisciplineIdsTaskAsync(result) is List <DisciplineVO> disciplines)) { return(null); } if (!(await _studentRepository.AddTaskAsync(studentEntity) is StudentModel addedStudent)) { return(null); } //await _emailSender.SendEmailTaskAsync(addedStudent.Email); return(_studentDisciplineConverter.Parse((addedStudent, _disciplineConverter.ParseList(disciplines)))); }
public bool modifyStudent(StudentVO student) { bool result = false; XmlNode students = mDoc.LastChild; XmlNodeList studentNodes = students.ChildNodes; foreach (XmlNode node in studentNodes) { XmlNodeList attrs = node.ChildNodes; if (attrs[3].InnerText.Equals(student.StuId)) { attrs[0].InnerText = student.Name; attrs[1].InnerText = student.Age + ""; attrs[2].InnerText = getGenderString(student.Gender); attrs[4].ChildNodes[0].InnerText = getDepartmentString(student.Department); attrs[4].ChildNodes[1].InnerText = student.Major; result = true; } } if (result) { mDoc.Save(xmlPath); } return(false); }
/* public string GetAllStudents(int studentid) * { * string studentName = ""; * try * { * DBConnection.conn.Open(); * String query = "select studentid, firstname+' '+lastname as name from student where active='Yes'"; * SqlCommand cmd = new SqlCommand(query, DBConnection.conn); * cmd.Parameters.AddWithValue("@StudentId", studentid); * SqlDataReader reader = cmd.ExecuteReader(); * if (reader.HasRows) * { * while (reader.Read()) * { * studentName = reader[0].ToString(); * } * } * } * catch (SqlException e) * { * ExceptionUtility.LogException(e, "Error Page"); * } * catch (Exception e) * { * ExceptionUtility.LogException(e, "Error Page"); * } * finally * { * if (DBConnection.conn != null) * { * DBConnection.conn.Close(); * } * } * return studentName; * }*/ // Get all studentid from database except dummy record in student table public List <StudentVO> GetAllStudentId() { List <StudentVO> allStudentId = new List <StudentVO>(); try { DBConnection.conn.Open(); string getCourseCode = "SELECT StudentId from Student where StudentId!=0"; SqlCommand command = new SqlCommand(getCourseCode, DBConnection.conn); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { StudentVO studentVO = new StudentVO(int.Parse(reader[0].ToString())); allStudentId.Add(studentVO); } } catch (Exception e) { ExceptionUtility.LogException(e, "Error Page"); throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message); } finally { if (DBConnection.conn != null) { DBConnection.conn.Close(); } } return(allStudentId); }
public void UpdateStudent(StudentVO studentVO) { var temp = GetStudent(studentVO.GetRollNo()); if (temp != null) { temp.SetName(studentVO.GetName()); } }
public StudentBO() { _students = new List <StudentVO>(); StudentVO student1 = new StudentVO("Robert", 0); StudentVO student2 = new StudentVO("John", 1); _students.Add(student1); _students.Add(student2); }
public async Task <IActionResult> UpdateStudentTaskAsync([FromBody] StudentVO newStudent) { if (ModelState.IsValid) { var coordId = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); if (await _courseBusiness.FindByCoordIdTaskAsync(coordId) is CourseVO course) { if (course.CourseId != newStudent.CourseId) { return(Unauthorized("Você não tem permissão para atualizar informações de um aluno de outro curso!")); } } if (!(await _studentBusiness.FindByStudentIdTaskAsync(newStudent.StudentId) is StudentDisciplineVO studentVO)) { return(NotFound("Não existe um aluno com esse Id")); } if (string.IsNullOrEmpty(newStudent.Name)) { return(BadRequest("É necessario informar o nome!")); } if (string.IsNullOrEmpty(newStudent.Email)) { return(BadRequest("É necessario informar o email!")); } if (await _studentBusiness.ExistsByEmailTaskAsync(newStudent.Email)) { if (studentVO.Student.Email != newStudent.Email) { return(Conflict("Ja existe um aluno com esse email!")); } } if (string.IsNullOrEmpty(newStudent.Disciplines)) { return(BadRequest("É preciso informar pelo menos uma disciplina!")); } if (await _studentBusiness.UpdateTaskAsync(newStudent) is StudentDisciplineVO student) { return(Created($"/Students/{student.Student.StudentId}", student)); } return(UnprocessableEntity("Não foi possivel atualizar os dados, verifique se o estudante realmente existe!")); } return(BadRequest()); }
public Boolean DeleteStudent(StudentVO instudent) { Boolean status = false; try { status = studentDao.DeleteStudent(instudent); } catch (CustomException e) { throw e; } return(status); }
// Add student details public Boolean AddStudent(StudentVO instudent) { bool status = false; try { DBConnection.conn.Open(); String query = "INSERT INTO dbo.Student (StudentID, FirstName, LastName, Status, CreatedDTM, UpdatedDTM) VALUES (@StudentId,@FirstName,@LastName, @Status,@CreatedDate,@UpdatedDate)"; SqlCommand cmd = new SqlCommand(query, DBConnection.conn); cmd.Parameters.AddWithValue("@StudentId", instudent.StudentId); cmd.Parameters.AddWithValue("@FirstName", instudent.FirstName); cmd.Parameters.AddWithValue("@LastName", instudent.LastName); cmd.Parameters.AddWithValue("@Status", ApplicationConstants.StudentStudyStatus); cmd.Parameters.AddWithValue("@CreatedDate", instudent.CreatedDate); cmd.Parameters.AddWithValue("@UpdatedDate", instudent.LastUpdatedDate); int result = cmd.ExecuteNonQuery(); if (result > 0) { status = true; } } catch (SqlException e) { ExceptionUtility.LogException(e, "Error Page"); if (e.Number == 2601) { throw new CustomException("StudentID already exists"); } else { throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message); } } catch (Exception e) { ExceptionUtility.LogException(e, "Error Page"); throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message); } finally { if (DBConnection.conn != null) { DBConnection.conn.Close(); } } return(status); }
// update student details public Boolean UpdateStudent(StudentVO instudent) { bool status = false; try { DBConnection.conn.Open(); String query = "UPDATE dbo.Student SET StudentID=@StudentId, FirstName=@FirstName, LastName=@LastName, Status=@Status,UpdatedDTM=@UpdatedDTM WHERE StudentID=@StudentId"; SqlCommand cmd = new SqlCommand(query, DBConnection.conn); cmd.Parameters.AddWithValue("@StudentId", instudent.StudentId); cmd.Parameters.AddWithValue("@FirstName", instudent.FirstName); cmd.Parameters.AddWithValue("@LastName", instudent.LastName); cmd.Parameters.AddWithValue("@Status", instudent.Status); cmd.Parameters.AddWithValue("@UpdatedDTM", DateTime.Now); int result = cmd.ExecuteNonQuery(); if (result > 0) { status = true; } } catch (SqlException e) { ExceptionUtility.LogException(e, "Error Page"); if (e.Number == 2601) { throw new CustomException("StudentID already exists"); } else { throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message); } } catch (Exception e) { ExceptionUtility.LogException(e, "Error Page"); throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message); } finally { if (DBConnection.conn != null) { DBConnection.conn.Close(); } } return(status); }
public async Task <IActionResult> AddStudentTaskAsync([FromBody] StudentVO newStudent) { if (ModelState.IsValid) { var coordId = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); if (await _courseBusiness.FindByCoordIdTaskAsync(coordId) is CourseVO course) { if (course.CourseId != newStudent.CourseId) { return(Unauthorized("Você não tem permissão para atualizar informações de um aluno de outro curso!")); } } if (string.IsNullOrEmpty(newStudent.Name)) { return(BadRequest("É necessario informar o nome!")); } if (string.IsNullOrEmpty(newStudent.Email)) { return(BadRequest("É necessario informar o email!")); } if (await _studentBusiness.ExistsByEmailTaskAsync(newStudent.Email)) { return(Conflict("Ja existe um aluno com esse email!")); } if (string.IsNullOrEmpty(newStudent.Disciplines)) { return(BadRequest("É preciso informar pelo menos uma disciplina!")); } if (await _studentBusiness.AddTaskAsync(newStudent) is StudentDisciplineVO createdStudent) { return(Created("/students", createdStudent)); } return(BadRequest("O formato das disciplinas do estudante não está valida (guid;guid;guid)")); } return(BadRequest()); }
public bool insertStudent(StudentVO student) { foreach (StudentVO vo in stuList) { if (vo.StuId.Equals(student.StuId)) { return(false); } } XmlNode students = mDoc.LastChild; XmlElement singleStudent = mDoc.CreateElement("student", mDoc.DocumentElement.NamespaceURI); XmlElement eleName = mDoc.CreateElement("name", mDoc.DocumentElement.NamespaceURI); eleName.InnerText = student.Name; XmlElement eleAge = mDoc.CreateElement("age", mDoc.DocumentElement.NamespaceURI); eleAge.InnerText = student.Age.ToString(); XmlElement eleGender = mDoc.CreateElement("gender", mDoc.DocumentElement.NamespaceURI); eleGender.InnerText = getGenderString(student.Gender); XmlElement eleMAJOR = mDoc.CreateElement("major", mDoc.DocumentElement.NamespaceURI); XmlElement eleStuId = mDoc.CreateElement("stuId", mDoc.DocumentElement.NamespaceURI); eleStuId.InnerText = student.StuId; XmlElement eleDepartment = mDoc.CreateElement("department", mDoc.DocumentElement.NamespaceURI); eleDepartment.InnerText = getDepartmentString(student.Department); XmlElement eleMajor = mDoc.CreateElement("major", mDoc.DocumentElement.NamespaceURI); eleMajor.InnerText = student.Major; eleMAJOR.AppendChild(eleDepartment); eleMAJOR.AppendChild(eleMajor); singleStudent.AppendChild(eleName); singleStudent.AppendChild(eleAge); singleStudent.AppendChild(eleGender); singleStudent.AppendChild(eleStuId); singleStudent.AppendChild(eleMAJOR); students.AppendChild(singleStudent); mDoc.Save(xmlPath); stuList.Add(student); return(true); }
public async Task <ResultModel <StudentDisciplineVO> > AddStudentTaskAsync(StudentVO student, string token) { IRestResponse response = await SendRequestTaskAsync(); return(response.StatusCode switch { HttpStatusCode.Created => new ResultModel <StudentDisciplineVO> { Object = JsonSerializer.Deserialize <StudentDisciplineVO>(response.Content, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }), Message = "Aluno adicionado com Sucesso!", StatusCode = response.StatusCode }, _ => new ResultModel <StudentDisciplineVO> { Message = response.Content.Replace("\"", string.Empty), StatusCode = response.StatusCode } });
public void Main() { StudentBO studentBusinessObject = new StudentBO(); //输出所有的学生 for (int i = 0; i < studentBusinessObject.GetAllStudent().Count; i++) { Console.WriteLine("Name:" + studentBusinessObject.GetAllStudent()[i].GetName() + "RollNo:" + studentBusinessObject.GetAllStudent()[i].GetRollNo()); } //更新学生 StudentVO student = studentBusinessObject.GetAllStudent()[0]; student.SetName("Michael"); studentBusinessObject.UpdateStudent(student); //获取学生 student = studentBusinessObject.GetStudent(0); Console.WriteLine("Name:" + student.GetName() + "RollNo:" + student.GetRollNo()); }
public async Task <StudentDisciplineVO> UpdateTaskAsync(StudentVO newStudent) { if (!(await _studentRepository.FindByStudentIdTaskAsync(newStudent.StudentId) is StudentModel studentModel)) { return(null); } if (!(await _studentRepository.UpdateTaskAsync(studentModel, _studentConverter.Parse(newStudent)) is StudentModel newStudentModel)) { return(null); } if (!GuidFormat.TryParseList(newStudentModel.Disciplines, ';', out List <Guid> disciplineIDs)) { return(null); } if (!(await _disciplineBusiness.FindAllByDisciplineIdsTaskAsync(disciplineIDs) is List <DisciplineVO> disciplines)) { return(null); } return(_studentDisciplineConverter.Parse((newStudentModel, _disciplineConverter.ParseList(disciplines)))); }
public static void Main(string[] args) { StudentBO studentBusinessObject = new StudentBO(); // Print all students foreach (StudentVO stud in studentBusinessObject.GetAllStudents()) { Console.WriteLine("Student [No : {0}, Name : {1}]", stud.RollNo, stud.Name); } Console.WriteLine("\n"); // Update students StudentVO student = studentBusinessObject.GetAllStudents()[0]; student.Name = "Claire"; studentBusinessObject.UpdateStudent(student); // Get the student student = studentBusinessObject.GetStudentByNo(student.RollNo); Console.WriteLine("Student [No : {0}, Name : {1}]", student.RollNo, student.Name); Console.ReadLine(); }
// delete the given student public Boolean DeleteStudent(StudentVO instudent) { Boolean status = false; try { DBConnection.conn.Open(); String query = "DELETE FROM dbo.Student WHERE StudentID=@StudentId"; SqlCommand cmd = new SqlCommand(query, DBConnection.conn); cmd.Parameters.AddWithValue("@StudentId", instudent.StudentId); cmd.ExecuteNonQuery(); int result = cmd.ExecuteNonQuery(); if (result > 0) { status = true; } } catch (SqlException e) { ExceptionUtility.LogException(e, "Error Page"); throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message); } catch (Exception e) { ExceptionUtility.LogException(e, "Error Page"); throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message); } finally { if (DBConnection.conn != null) { DBConnection.conn.Close(); } } return(status); }
protected void btnAddStudent_Click(object sender, EventArgs e) { try { DBConnection.conn.Open(); SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM dbo.Student WHERE StudentID =" + Convert.ToInt32(txtStudentID.Text.Trim()), DBConnection.conn); Int32 count = (Int32)cmd.ExecuteScalar(); DBConnection.conn.Close(); if (count > 0) { Response.Write("<script>alert('StudentID already exists.');</script>"); } else if (!txtEmail.Text.Trim().EndsWith("@ess.ais.ac.nz")) { Response.Write("<script>alert('Please enter valid email (e.g. [email protected])');</script>"); } DBConnection.conn.Open(); SqlCommand cmd1 = new SqlCommand("SELECT COUNT(*) FROM dbo.IlmpUser WHERE EmailId ='" + txtEmail.Text.Trim() + "'", DBConnection.conn); Int32 count1 = (Int32)cmd1.ExecuteScalar(); DBConnection.conn.Close(); if (count1 > 0) { Response.Write("<script>alert('Email already exists, please check email Student');</script>"); } else { bool valid = ValidateControls(); if (valid) { int studentID = 0; try { studentID = Int32.Parse(txtStudentID.Text); } catch (ParseException) { Response.Write("<script>alert('Please enter valid studentid');</script>"); } string firstName = txtFirstName.Text; string lastName = txtLastName.Text; string status = "Studying"; string emailID = txtEmail.Text; DateTime createdDTM = DateTime.Now; DateTime updatedDTM = DateTime.Now; StudentVO studentVO = new StudentVO(studentID, firstName, lastName, status, createdDTM, updatedDTM); UserVO userVO = new UserVO(); userVO.StudentID = studentID; userVO.StaffID = 0; userVO.EmailID = emailID; userVO.Role = ApplicationConstants.StudentRole; if (lbMajor.Items.Count == 0) { Response.Write("<script>alert('Please choose major');</script>"); } else if (studentBO.AddStudent(studentVO)) { for (int i = 0; i < lbMajor.Items.Count; i++) { ListItem lmajor = lbMajor.Items[i]; StudentMajorVO studentMajorVO = new StudentMajorVO(studentID, ddlProgramme.SelectedItem.Value, lmajor.Value, "Yes"); StudentMajorBO studentMajorBO = new StudentMajorBO(); if (studentMajorBO.AddStudent(studentMajorVO)) { Response.Write("<script>alert('Student added successfully');</script>"); } else { Response.Write("<script>alert('Error in adding student major');</script>"); } } UserBO userBO = new UserBO(); userBO.AddUser(userVO); } else { Response.Write("<script>alert('Error in adding student');</script>"); } } else { Response.Write("<script>alert('Please enter all student details');</script>"); } } } catch (CustomException ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } catch (Exception ex) { Response.Write("<script>alert('Error in adding student');</script>"); ExceptionUtility.LogException(ex, "Error Page"); } Clear(); }
public void DeleteStudent(StudentVO student) { _students.Remove(student); Console.WriteLine(student.GetName() + "--" + student.GetRollNo()); }
static public void Fill(byte[] bytes) { var binReader = new EndianBinaryReader(Endian.LittleEndian, new MemoryStream(bytes)); binReader.Endian = binReader.ReadBoolean() ? Endian.LittleEndian : Endian.BigEndian; var jumpPos = binReader.ReadInt32(); //跳过表头信息 binReader.BaseStream.Position = jumpPos; /* var headerCount = binReader.ReadInt32(); var headers = new string[headerCount]; var types = new string[headerCount]; for (var i = 0; i < headerCount; i++) { headers[i] = binReader.ReadUTF(); types[i] = binReader.ReadUTF(); } */ var count = binReader.ReadInt32(); for (int i = 0; i < count; i++) { var vo = new StudentVO(); vo.decode(binReader); list_vo.Add(vo); dic_vo.Add(vo.Name, vo); } }
protected void btnUpload_Click(object sender, EventArgs e) { string existingStudent = ""; string failedStudent = ""; bool studentExists = false; try { List <StudentMajorVO> studentPgmVOList = new List <StudentMajorVO>(); List <StudentVO> studentVOList = new List <StudentVO>(); List <UserVO> users = new List <UserVO>(); UserDaoImpl userDaoImpl = new UserDaoImpl(); UserVO userVO = null; IStudentDao studentDao = new StudentDaoImpl(); List <string> existingStudentIDList = studentDao.GetAllStudentIDAsList(); string filepath = Server.MapPath("~/Files/") + Path.GetFileName(fuBulkCourseUpload.PostedFile.FileName); if (fuBulkCourseUpload.HasFile) { fuBulkCourseUpload.SaveAs(filepath); string data = File.ReadAllText(filepath); Boolean headerRowHasBeenSkipped = false; foreach (string row in data.Split('\n')) { if (headerRowHasBeenSkipped) { string programme = ""; studentExists = false; if (!string.IsNullOrEmpty(row)) { userVO = new UserVO(); StudentVO studentVO = new StudentVO(); StudentMajorVO studentMajorVO = new StudentMajorVO(); List <string> pgmList = new List <string>(); int i = 0; foreach (string cell in row.Split(',')) { if (!studentExists) { string celltemp = ""; if (cell.Contains("\r")) { celltemp = cell.Replace("\r", ""); } else { celltemp = cell; } celltemp = celltemp.Trim(); switch (i) { case 0: { if (existingStudentIDList.Contains(celltemp)) { existingStudent += celltemp + ","; studentExists = true; } else { studentVO.StudentId = Convert.ToInt32(celltemp); studentMajorVO.studentId = Convert.ToInt32(celltemp);; userVO.StudentID = Convert.ToInt32(celltemp); } break; } case 1: { studentVO.FirstName = celltemp; break; } case 2: { studentVO.LastName = celltemp; break; } case 3: { /* if (celltemp.Contains("&")) * { * foreach (string pgm in celltemp.Split('&')) * { * pgmList.Add(pgm); * } * } * else * { * pgmList.Add(celltemp); * }*/ programme = celltemp; break; } case 4: { if (celltemp.Contains("&")) { StudentMajorVO sm; // foreach (string pgm in pgmList) //{ foreach (string mjr in celltemp.Split('&')) { sm = new StudentMajorVO(); sm.StudentId = studentMajorVO.StudentId; sm.ProgrammeID = programme; sm.MajorID = mjr.Trim(); studentPgmVOList.Add(sm); } // } } else { StudentMajorVO sm; // foreach (string pgm in pgmList) //{ sm = new StudentMajorVO(); sm.StudentId = studentMajorVO.StudentId; sm.ProgrammeID = programme; sm.MajorID = celltemp; studentPgmVOList.Add(sm); //} } break; } case 5: { if (!celltemp.EndsWith("@ess.ais.ac.nz")) { existingStudent += celltemp + ","; studentExists = true; } else { userVO.EmailID = celltemp; } break; } } } i++; } if (!studentExists) { studentVO.Program = studentPgmVOList; users.Add(userVO); studentVOList.Add(studentVO); } } } headerRowHasBeenSkipped = true; } if (studentVOList.Count > 0) { foreach (StudentVO studentVO in studentVOList) { studentVO.Status = "Studying"; studentVO.CreatedDate = DateTime.Now; studentVO.LastUpdatedDate = DateTime.Now; string status = (studentBO.AddStudent(studentVO)).ToString(); if (status.Contains("fail")) { failedStudent += studentVO.StudentID; } } foreach (StudentMajorVO studentMajorVO in studentPgmVOList) { studentMajorVO.Active = "Yes"; string status = (studentMajorBO.AddStudent(studentMajorVO)).ToString(); if (status.Contains("fail")) { failedStudent += studentMajorVO.StudentId; } } userDaoImpl.AddStudentUsers(users); string usermessage = " Students upload completed."; if (failedStudent != "") { usermessage += " FailedStudentList " + failedStudent; } if (existingStudent != "") { usermessage += " Skipped existing student. " + existingStudent; } ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + usermessage + "');", true); } } } catch (Exception ex) { ExceptionUtility.LogException(ex, "Error Page"); Response.Write("<script>alert('" + ex.Message + "');</script>"); } finally { if (DBConnection.conn != null) { DBConnection.conn.Close(); } } }
protected void btnUpdateStudent_Click(object sender, EventArgs e) { try { int studentID = Convert.ToInt32(txtStudentID.Text.Trim()); string firstName = txtFirstName.Text.Trim(); string lastName = txtLastName.Text.Trim(); string programmeId = ddlStudentProgramme.SelectedValue.Trim(); string emailID = txtEmailID.Text.Trim(); string status = ddlStatus.Text.Trim(); DateTime updatedDTM = DateTime.Now; string active = ""; if (ddlStatus.Text != "Studying") { active = "No"; } else { active = "Yes"; } if (!txtEmailID.Text.Trim().EndsWith("@ess.ais.ac.nz")) { Response.Write("<script>alert('Please enter valid email ess.ais.ac.nz');</script>"); } StudentVO studentVO = new StudentVO(studentID, firstName, lastName, status, updatedDTM); UserVO userVO = new UserVO(studentID, emailID, active); if (active == "No" || status == "Withdrawn" || status == "Graduated" || status == "Postponed") { ILMPBO ilmpBO = new ILMPBO(); bool ilmpUpdationStatus = ilmpBO.UpdateILMPStatusForStudent(studentID, "No"); } if (txtFirstName.Text == "" || txtLastName.Text == "" || txtEmailID.Text == "" || lbMajor.Items.Count == 0) { Response.Write("<script>alert('Please check First Name, Last Name, Email and Major is filled');</script>"); } else if (studentBO.UpdateStudent(studentVO) && userBO.UpdateUser(userVO)) { DBConnection.conn.Open(); string query = "DELETE FROM StudentMajor WHERE StudentID=" + studentID; SqlCommand cmd2 = new SqlCommand(query, DBConnection.conn); cmd2.ExecuteNonQuery(); DBConnection.conn.Close(); for (int i = 0; i < lbMajor.Items.Count; i++) { ListItem lmajor = lbMajor.Items[i]; StudentMajorVO studentMajorVO = new StudentMajorVO(studentID, programmeId, lmajor.Value, active); StudentMajorBO studentMajorBO = new StudentMajorBO(); if (studentMajorBO.AddStudent(studentMajorVO)) { Response.Write("<script>alert('Student updated successfully');</script>"); } else { Response.Write("<script>alert('Error in updating student major');</script>"); } } } else { Response.Write("<script>alert('Student update Fail');</script>"); } } catch (CustomException ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } catch (SqlException ex) { ExceptionUtility.LogException(ex, "Error Page"); Response.Write("<script>alert('" + ex.Message + "');</script>"); } catch (Exception ex) { ExceptionUtility.LogException(ex, "Error Page"); Response.Write("<script>alert('Student updation failed');</script>"); } }