Exemplo n.º 1
0
 public List()
 {
     InitializeComponent();
     CreateDataTable();
     CreateEventTable();
     stud = new Student();
     event1 = new Event();
     studComm = new StudentCommands(Properties.Settings.Default.connection);
 }
Exemplo n.º 2
0
        public void DeleteStudent(Student stud)
        {
            string deleteString = "DELETE FROM Student WHERE id = '" + stud.IdStudent + "'";

            using (conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand command = new SqlCommand(deleteString, conn);
                command.ExecuteNonQuery();
                conn.Close();
            }
        }
Exemplo n.º 3
0
        public StudentOrganizer.BO.Student SearchStudent(int studID)
        {
            StudentOrganizer.BO.Student student = new StudentOrganizer.BO.Student();
            student.IdStudent = studID;

            string searchString = "SELECT * FROM student where id = " + student.IdStudent;

            using (conn = new SqlConnection(connectionString))
            {
                conn.Open();

                SqlCommand command = new SqlCommand(searchString, conn);
                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {

                        student.FirstName = reader.GetString(reader.GetOrdinal("FirstName"));
                        student.LastName = reader.GetString(reader.GetOrdinal("LastName"));
                        student.Gender = reader.GetString(reader.GetOrdinal("Gender"));
                        student.Gender = reader.GetString(reader.GetOrdinal("Email"));
                        student.BirthDate = reader.GetDateTime(reader.GetOrdinal("BirthDate"));
                        student.PhoneNumber = reader.GetString(reader.GetOrdinal("PhoneNumber"));
                        student.Faculty = reader.GetString(reader.GetOrdinal("Faculty"));
                        student.FacultyStartYear = reader.GetString(reader.GetOrdinal("FacultyStartYear"));
                    }
                    reader.Close();
                }

                conn.Close();
            }

            return student;
        }