public SchoolMessageFrm() { InitializeComponent(); stu = studao.read(4); school = schodao.FindOne(stu.getSchoolID()); listView1.View = View.Details; // Allow the user to edit item text. listView1.LabelEdit = true; // Allow the user to rearrange columns. listView1.AllowColumnReorder = true; // Display check boxes. listView1.CheckBoxes = true; // Select the item and subitems when selection is made. listView1.FullRowSelect = true; // Display grid lines. listView1.GridLines = true; // Sort the items in the list in ascending order. listView1.Sorting = SortOrder.Ascending; listView1.Columns.Add("AUTHOR", -2, HorizontalAlignment.Left); listView1.Columns.Add("MESSAGE", -2, HorizontalAlignment.Left); List<Message> list = mesdao.findAllSchool(1); ListViewItem item; foreach (Message m in list) { item = new ListViewItem(m.Autor.getForename(), 1); item.SubItems.Add(m.MessageDetail); listView1.Items.AddRange(new ListViewItem[] { item }); } }
//Author: Niall Stack - t00174406 public StudentImpl create(int studentID, string forename, string surname, string dob, int schoolID, int groupID, string gender, Byte[] pictureCol, string password, string studentNumber, string status) { StudentImpl student; //throw new NotImplementedException(); try { if (studentID == null) { throw new ArgumentNullException("Student ID"); } string connectionString = GetConnectionString("sw4", "sw4"); using (OracleConnection connection = new OracleConnection()) { connection.ConnectionString = connectionString; connection.Open(); OracleCommand command = connection.CreateCommand(); string sql = "INSERT INTO Students (studentID, forename, surname, dob, schoolID, classID, gender, image, studentpassword, studentNumber, status) VALUES (" + studentID + ",'" + forename + "','" + surname + "','" + dob + "'," + schoolID + "," + groupID + ",'" + gender + "','" + null + "','" + password + "','" + studentNumber + "','" + status + "')"; command.CommandText = sql; command.ExecuteNonQuery(); student = new StudentImpl(studentID, forename, surname, dob, schoolID, groupID, gender, pictureCol, password, studentNumber, status); connection.Close(); } } catch (NotImplementedException e) { return null; } return student; }
//Author: Aleksandar Zoric public StudentImpl read(int studentID) { try { StudentImpl student; if (studentID == null) { throw new ArgumentNullException("Student ID"); } string connectionString = GetConnectionString("sw4", "sw4"); using (OracleConnection connection = new OracleConnection()) { connection.ConnectionString = connectionString; connection.Open(); OracleCommand command = connection.CreateCommand(); string sql = "SELECT * FROM Students WHERE StudentID = " + studentID; command.CommandText = sql; OracleDataReader reader; reader = command.ExecuteReader(); reader.Read(); Int32 studentid = Convert.ToInt32(reader["studentID"]); String forename = (string)reader["forename"]; String surname = (string)reader["surname"]; String dob = (string)reader["dob"].ToString(); Int32 schoolD = Convert.ToInt32(reader["schoolID"]); Int32 classID = Convert.ToInt32(reader["classID"]); String gender = (string)reader["gender"]; Byte[] image = null; if (!Convert.IsDBNull(reader["image"])) { image = (Byte[])reader["image"]; } String studentPassword = (string)reader["studentpassword"]; String studentnumber = (string)reader["studentnumber"].ToString(); String status = (string)reader["status"].ToString(); student = new StudentImpl(studentid, forename, surname, dob, schoolD, classID, gender, image,studentPassword, studentnumber, status); command.ExecuteNonQuery(); connection.Close(); return student; } } catch(NotImplementedException e) { return null; } }