コード例 #1
0
ファイル: List.cs プロジェクト: teneaandrei/GitHub
 public List()
 {
     InitializeComponent();
     CreateDataTable();
     CreateEventTable();
     stud = new Student();
     event1 = new Event();
     studComm = new StudentCommands(Properties.Settings.Default.connection);
 }
コード例 #2
0
ファイル: StudentCommands.cs プロジェクト: teneaandrei/GitHub
        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();
            }
        }
コード例 #3
0
ファイル: StudentCommands.cs プロジェクト: teneaandrei/GitHub
        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;
        }