Exemple #1
0
        public int DeleteStudent(string studentId)
        {
            int i = 0;

            if (GetOneStudentById(studentId) != null)
            {
                using (SqlCommand command = new SqlCommand())
                {
                    i = ExecuteNonQuery(StudentStringsSql.DeleteStudent(studentId));
                }
            }
            return(i);
        }
Exemple #2
0
        public StudentModel UpdateStudent(StudentModel studentModel)
        {
            DataTable dt = new DataTable();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(StudentStringsSql.UpdateStudent(studentModel));
            }
            foreach (DataRow ms in dt.Rows)
            {
                studentModel = StudentModel.ToObject(ms);
            }

            return(studentModel);
        }
Exemple #3
0
        public List <StudentModel> GetAllStudents()
        {
            DataTable dt = new DataTable();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(StudentStringsSql.GetAllStudents());
            }

            List <StudentModel> arrStudent = new List <StudentModel>();

            foreach (DataRow ms in dt.Rows)
            {
                arrStudent.Add(StudentModel.ToObject(ms));
            }

            return(arrStudent);
        }
Exemple #4
0
        public StudentModel GetOneStudentById(string studentId)
        {
            DataTable dt = new DataTable();

            if (studentId.Equals(string.Empty) || studentId.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }
            StudentModel studentModel = new StudentModel();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(StudentStringsSql.GetOneStudentById(studentId));
            }

            foreach (DataRow ms in dt.Rows)
            {
                studentModel = StudentModel.ToObject(ms);
            }

            return(studentModel);
        }